看板 PHP 關於我們 聯絡資訊
※ 引述《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)