The Apache Pools
Fortunately, Apache makes this easy for us, by providing different pools
for different types of resource. These pools are associated with relevant
structures of the httpd, and have the lifetime of the corresponding struct.
There are four general-purpose pools always available in Apache
- the request pool, with the lifetime of an HTTP request.
- the process pool, with the lifetime of an server process.
- the connection pool, with the lifetime of a TCP connection.
- the configuration pool
The first three are associated with the relevant Apache structs, and
accessed as request->pool, connection->pool and process->pool
respectively. The fourth, process->pconf, is also associated with
the process, but differs from the process pool because it is
cleared whenever Apache re-reads its configuration.
The process pool is suitable for long-lived resources, such as those
which are initialised at server startup, or those cached for re-use
over multiple requests. The request pool is suitable for transient
resources used to process a single request.
A third general-purpose pool is the connection pool, which has the
lifetime of a connection - being one or more Request. This is useful
for transient resources that cannot be associated with a request:
most notably in a connection-level filter, where the request_rec
structure is undefined.
In addition to these, special-purpose pools are created for other
purposes including configuration and logging, or may be created
privately by modules for their own use.