PHP and mod_dbd

早过忘川 提交于 2019-12-24 13:33:20

问题


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.


回答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




回答2:


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.



来源:https://stackoverflow.com/questions/1861876/php-and-mod-dbd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!