作者foxzgerald (O⊥M)
看板PHP
标题Re: connection pool ?
时间Sun May 27 14:08:44 2007
※ 引述《kenshieh ( )》之铭言:
: 请问在 PHP 中是否有可能实现 connection pool ?
: 试了各式各样的方法,几乎都无法把 Resource #id 存起来,不知是否有其它解决方法
: 呢? 谢谢。 :>
pooling 应该是 apache 所做的事情吧
曾经看过一篇 Rasmus Lerdorf(php 之父)的 interview 对於 pooling
这个问题有以下的回应(SP为记者;RL则是 Rasmus Lerdorf):
[原文:
http://www.sitepoint.com/article/phps-creator-rasmus-lerdorf/4 ]
x x x
SP: What about database connection pooling?
Persistent connections are not
nearly good enough - are there plans to implement connection pooling in the
future?
RL: A pool of connections has to be owned by a
single process. Since most
people use the
Apache Web server, which is a multi-process pre-forking
server, there is simply
no way that PHP can do this connection pooling. It
has to be done by a dedicated standalone process and is
quite outside the
scope of PHP itself. Both SQLRelay and SRM can be used to solve this problem.
If/when the common architecture for PHP is a single-process multithreaded Web
server, we might consider putting this functionality into PHP itself, but
until that day it really doesn't make much sense.
Even Apache 2 is still
going to be a multi-process server with each process being able to carry
multiple threads.
So we could potentially have a pool of connections in each
process.
x x x
如果要达到类似 connection pooling 的效果,应该是使用 persistent connections;
至少它在连结之前,会先查看是否与资料库间已建有连结,若已建立便使用该连结,
若无才会建立新的。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.119.199.121
※ 编辑: foxzgerald 来自: 140.119.199.121 (05/27 14:10)