- Pool connections - Connection pooling is basic. There’s no excuse not to do it. It probably makes sense to use an established library instead of coding a pooling implementation by hand.
- Protect request-handling threads - Do not allow callers to block forever. Make sure that any checkout call has a timeout and that the caller knows what to do when it doesn’t get a connection back.
- Size the pools for maximum throughput - Undersized resource pools lead to contention and increased latency. This defeats the purpose of pooling the connections in the first place. Monitor calls to the connection pools to see how long your threads are waiting to check out connections.
Search This Blog
Friday, April 23, 2010
Release It! - Chapter 10. 1 Pool Connections
Resource pools can dramatically improve capacity. Resource pools eliminate connection setup time. Establishing a new database connection requires a TCP connection, database authentication, and database session setup. Taken together, this can easily take 400 to 500 milliseconds. Only starting a new thread is more expensive than creating a database connection. Connection pool sizing is a vital issue. An undersized connection pool leads to resource pool contention. An oversized connection pool can cause excess stress on the database servers. You must monitor your connection pools for contention, or this capacity enhancer will quickly become a killer.