I'm wrapping up a small project and I'm doing some performance tuning before the initial release. It's a web application so it only receives HTTP requests in the form of XHR and page load requests.
At application startup, a DataSource is retrieved from the Tomcat server (via JNDI) and stored in the application. It's a
oracle.jdbc.xa.client.OracleXADataSource and as far as I can tell (from what I've read and observed) it is pooling connections.
In the application, each request to the server gets its own connection opened at the first SQL call (if one occurs). At the end of each request, the connection is closed (if one was opened).
So as part of my performance tuning, I'm trying to improve the responsiveness of these requests by reducing the time it takes to make the database connection. What would you consider to be acceptable amount of time to establish a database connection?
Here's my benchmarks so far, each request -
- 324 ms (1st request just after restarting the application)
- 51 ms
- 58 ms
- 56 ms
- 53 ms
- 51 ms
- 49 ms
- 48 ms
After the 1st connection has been open and "closed" it looks like the connection is pooled and reused. Is ~50ms a pretty standard amount of time to establish a connection from a pooled data source?
long start = System.nanoTime(); //oracle.jdbc.xa.client.OracleXADataSource Connection connection = dataSource.getConnection(); log.info("Connection made in: " + ((System.nanoTime()-start)/1000000) + " ms.");