Thursday, April 09, 2009

OCI migration and performance


We recently moved our internal database to another server and instead of changing all the applications to point to the new server we converted all our applications from thin connection to Oracle OCI driver. The figure above shows the difference.

In OCI you refer to the database alias and not the physical machine + port + SID and hence you are protected from changes to the database physical server (if the database moves to a different server). The performance is much better too.

Also, during the change we switched to using the DBCP connection pooling which can be easily configured the the context.xml for Struts as

< Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
username="username"
password="password"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://example.com:1234/myDB"
maxWait="1000"
removeAbandoned="true"
maxActive="30"
maxIdle="10"
removeAbandonedTimeout="60"
logAbandoned="true"/>


Datasource can be obtained in the code using:-
try {
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/postgres");
} catch( NamingException ne ) {
throw new RuntimeException( "Unable to aquire data source", ne );
}
Our applications were zooming after the upgrade...

No comments:

Post a Comment

Thank you for your feedback