Dangerous Side Effects


Persistent database connections might save a lot of connection overhead, which can be a significant advantage ” especially when the load on your database server is high. As a rule of thumb, the higher the connection overhead is, the more speed can be gained by using persistent database connections. If you have just a few connections but a lot of queries, which take a long time to be executed, the gained speed will be comparatively low.

But Persistent database connections also have disadvantages. The more connections your database has to handle, the more memory that is wasted to keep backend processes in memory, which are not always working ones. Another problem is that the system cannot only run out of memory, but also runs out of file handles. Normally this happens only on servers with a lot of memory, but you have to make sure that file handles won't be a problem on your system.

Imagine another situation: You have configured Apache to accept 20 connections at a time, and you have told PostgreSQL to handle up to 16 connections simultaneously . Because every Apache process running should have its own backend, you might find yourself in deep trouble soon. Some Apache processes will not be able to connect to the database and errors will occur.

You should also make sure that transactions are committed correctly so that no open transactions will be in the system.

In general, persistent database connections are a good invention, and if they are used correctly, they can help you speed up your database significantly (depending on the type of application you want to run, of course).



PostgreSQL Developer's Handbook2001
PostgreSQL Developer's Handbook2001
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 125

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net