Is DB connection pooling all that important?

The main reason for connection pooling is the overhead in establishing the connection in the first instance. I have seen this take up to 0.5 seconds in the past In a high transactional environment, the ability to keep a connection open, and send multiple requests down the connection, one after the other have significant savings. Therefore, you may not see the gains in a low transactional database, but your application is not going to scale as well, if you ignore this useful pattern It also helps to managed the number of open connections in a much clearer way.

The main reason for connection pooling is the overhead in establishing the connection in the first instance. I have seen this take up to 0.5 seconds in the past. In a high transactional environment, the ability to keep a connection open, and send multiple requests down the connection, one after the other have significant savings.

Therefore, you may not see the gains in a low transactional database, but your application is not going to scale as well, if you ignore this useful pattern. It also helps to managed the number of open connections in a much clearer way.

It just means that there's no built-in connection pool for PHP. Doesn't mean you can't use one, though, for instance with Postgres you can use PGPool.

Connection polling is often used because some database vendors limit the number of connections that you have to a given database depending on your license. Open Source databases do not have such limits because they are free. So it is not much of a problem for MySQL.

Another reason to use connection polling is to limit the number of current connections to the database server, as each new connection consumes a lot of memory and you do not want to exhaust your servers memory. The problem with persistent connections is that they never close until the client processes die. Client processes are in reality the Web server processes handling PHP requests.So, if you configure your Web server to limit the number of simultaneous requests, you also limit the number of opened persistent database connections.

You can do that in Apache setting the MaxClients parameter to a reasonable value that does not exhaust your server RAM. More on this in this article about Best practices to prevent breaking your sites. Check point "6.

Damage control". BTW, it would also be wise to move all your static content (CSS, JavaScript, images, etc..) to a separate multithreaded Web server (Nginx, lighttpd, etc..) so the simultaneous user accesses do not make your Apache fork to much processes. More on this in this article about defensive programming practices to make your sites survive traffic peaks.

Check point "5. Move images, CSS and Javascript to a multi-threaded Web server".

I'm not sure the first paragraph is true. Connections are heavyweight objects thus they need to be pooled. It's not that particular database servers cannot handle 100s or 1000s of connections.

– cherouvim Feb 16 at 21:44 I did not say that is the only reason for using connection pooling. I just said it is often used for that reason, but there may be others. – mlemos Feb 17 at 23:03.

My general opinion is that connection pools generally aren't used in environments where speed isn't considered as important as other concerns. AOLServer, for example, uses a dynamic language (Tcl) but is highly performant and uses connection pools.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions