Re: Proposal: Establish DB connections during module_init
| From: | Zeev Suraski | Date: | Wed, 07 Jun 2000 05:46:55 +0000 |
| Subject: | Re: Proposal: Establish DB connections during module_init | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-20422@lists.php.net to get a copy of this message | ||
At 04:24 07/06/2000, Rasmus Lerdorf wrote:
I have run across a situation where the delay involved in establishing a connection is a bottleneck. The traditional answer to this is to use persistent connections. However, the problem is that with persistent connections the db connection is not established until the first request to a new httpd process which means that the unfortunate user that happens to be the first to that process will experience a delay. It should be possible to define the DB connection parameters in php.ini/httpd.conf and have the connection established during the module_init phase. Because of the pre-forking nature of Apache, the db connection delay will always happen right after a new httpd process is launched and such new processes are launched to satisfy the min_spare_servers setting. That means new processes are most likely to come up idle and no user would end up seeing the connection delay. Anybody see why this might be a bad idea? Of course it would be optionally triggered by config directives. We could use the existing default_host and default_user settings and just flick a switch. ie. <VirtualHost www.php.net> php_admin_value mysql.default_host=localhost php_admin_value mysql.default_user=rasmus php_admin_value mysql.default_password=foobar php_admin_value mysql.autoconnect=On ... </VirtualHost>Are you sure what you're saying actually happens? Does PHP's startup (module_init()) gets called for every process? AFAIK, it's only called for the main process (twice), and afterwards, Apache just forks with its entire post-startup memory image. If that's true - it's not quite possible to do what you're saying. If it's not true - well, then we need to think about it... Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/