Database Connections Are Performance Expensive
While reading the Data Access Handbook I came across some facts about database connections. These connections are established by any JEE application to the database server.
- Creating a connection is performance-expensive compared to all other tasks a database application can perform.
- Open connections use a substantial amount of memory on both the database server and database client machines.
- Establishing a connection takes multiple network round trips to and from the database server.
- Opening numerous connections can contribute to out-of-memory conditions, which might cause paging of memory to disk and, thus, overall performance degradation.
- In today’s architectures, many applications are deployed in connection pooled environments, which are intended to improve performance.However, many times poorly tuned connection pooling can result in performance degradation. Connection pools can be difficult to design, tune, and monitor.
Why Connections Are Performance Expensive
In reality, a connection typically involves many network round trips between the driver and the database server. For example, when a driver connectsto Oracle or Sybase, that connection may take anywhere from seven to ten network round trips to perform the following actions:
- Validate the user’s credentials.
- Negotiate code page settings between what the database driver expects and what the database has available, if necessary.
- Get database version information.
- Establish the optimal database protocol packet size to be used for communication.
- Set session settings.
In addition, the database management system establishes resources on behalf of the connection, which involves performance-expensive disk I/O and memory allocation.
Posted on June 25, 2011, in java, oracle-jdbc and tagged connections, jdbc. Bookmark the permalink. Leave a comment.
Leave a comment