tags:

views:

136

answers:

2

Hi all!

Here is something I can't understand. A lot of web frameworks internally use db pooling. I can't understand how the db pooling can work there, if HTTP connections are stateless? I can imagine that db pooling could work only for connections that are Keep-Alive?

Any ideas?

Thanks!

+2  A: 

The web server maintains a "pool" of established connections to the database. For each HTTP request, it can take one of the already-existing connections from the pool, for use during that one request. This can increase performance and reduce the server loads, since the web and database servers do not need to open new connections for each request (which can have a lot of overhead). The way the database connections are used, they too are stateless. The web server gets one of the connections, runs some queries, puts the connection back in the pool.

Adam Batkin
ah, got it. as simple as this. thanks!
Peteris Krumins
+2  A: 

A web application may accept multiple HTTP connections over its lifetime. The initial connection will establish the DB handle, and subsequent connections to the same application will re-use it.

John Millikin
thanks! makes sense.
Peteris Krumins