Peter Poeml wrote:
Hi,
On Fri, Nov 07, 2008 at 03:24:00PM +0100, B. F. wrote:
I have recently started using the mod_dbd module for database
connection handling in my own module and a had slight hope that it
would perform better than a classic persistent connection approach.
Basically I am using the ap_dbd_acquire(request_rec*) function in a
handler function (in my own module) and then uses some of the apr_dbd
functions to fetch data from a PostgreSQL database, all this seems
fine.
When I run a performance test (using httperf) with the prefork mpm I
get numbers like ~100 requests/s.
However when I run the same test but now using the worker mpm, this
number drops to almost nothing...
As I understood it, the worker (or any threaded mpm) should make
mod_dbd/apr_dbd perform better as it enables functionality needing
multi threading (like connection pooling) while prefork limits mod_dbd
to only use a persistent connection strategy. Despite this the prefork
mpm performs better...
I have tried several different configuration setups without seeing any
great difference. A typical setup is however: 200 max_connections (in
postgresql.conf, the same for both the prefork and worker tests).
Having DBDMax set to 10 while setting ServerLimit to 20 should fully
make mod_dbd utilize all the 200 available connections in Postgres, is
that correct?
ThreadsPerChild affects how many threads share each DBD pool with worker mpm.
If you are running with the default value of 25 ThreadsPerChild, then each of your 20 processes will
have up to 25 threads processing requests. Each process will have a pool of 10 DBD connections
(DBDMax) to share between its 25 threads.
When one of your processes is completely busy, some of the 25 threads must wait for one of the 10
DBD connections.
This could explain why you get lower throughput with your configuration, but it really doesn't
explain why you get "almost nothing" vs. ~100 requests/s.
You might want to try this configuration if you have a hard limit of 200
database connections:
ServerLimit 8
ThreadsPerChild 25
MaxClients 200
DBDMax 25
See http://httpd.apache.org/docs/2.2/mod/worker.html for the details about how worker mpm handles
threads & processes.
-tom-