1

Does anyone know a PHP extension to use mod_dbd for database connections?

Our application needs to access a remote database. It used to be an Apache module using mod_dbd for database connections and the transaction takes about 200ms. Now we changed the application to PHP and the same transaction takes over 600ms now. We hope some kind of pooling will improve the performance.

We switched to use mysql_pconnect() but it doesn't work nearly as good as mod_dbd.

2 Answers 2

1

I know you have probably given up on an answer but...

I think you'll find that most of the extra time is loading and compiling the PHP script. if your previous app was an apache module then it is precompiled and always loaded, probably written in c so very fast compared to PHP.

Try using a php accelerator like eaccelerator. that uses shared memory and precompiled scripts to sometimes dramatically improve the performance of PHP apps.

DC

Sign up to request clarification or add additional context in comments.

2 Comments

We know the PHP loading/compiling time is not the deciding factor because we only see a few milliseconds increase in other transaction without DB access.
I am surprised by that. have you done some profiling to determine exactly where the time is lost. could the db have changed in the meantime or the sql query is now different? even a slight difference may cause issues if it means an index is not used or the wrong index is used. mysql_pconnect often doesn't work as well as one hopes as you have found. I have always thought it would be good for php to use pooled connections. but pconnect is a per process connection. It also needs to be enabled in php.ini if you weren't aware of that.
0

In order to benefit from the connection pooling feature of mod_dbd you would need to run a threaded MPM so that several threads can share the connections in the pool. Unfortunately I do believe PHP is not thread-safe, and will not support threaded MPMs.

If you use mod_dbd with the pre-fork MPM (which is not threaded and recommended for PHP) mod_dbd will create a single persistent database connection, which does not give you any huge advantage compared to a database connection in PHP not using mod_dbd.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.