publish extension php-connect-pool
| From: | xinhua guo | Date: | Sat, 20 Dec 2014 04:15:49 +0000 |
| Subject: | publish extension php-connect-pool | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-12484@lists.php.net to get a copy of this message | ||
I am Gary live in china ,my Chinese name is xinhua.guo , i am a
phper , two years ago i work on sina, now i work on jumei.com ,and i
love php very much.
About the extension:
Start a proxy process and the process hold some tcp. Provide local
connection pool like java.
Require:
PHP 5.3 +(no zts , zts support in todo list)
linux 2.6+
pdo and redis extension installed
Technical characteristics:
1.After each time fetchAll (set/get) call release() method, release
the connection to the pool, avoid that the script jammed causing
connection occupy high problem.
2.The maximum and minimum number of connections configuration support.
3.Support small pressure automatic recovery connection.
4.Support graceful restart (reload).
5.Do a lot of optimization, although the request through the
connection pool process forward, but no loss of QPS.
6.When the connection use out,support queue.
7.Simple! just change the new method and add release function (see
demon),you used the tcp pool.
Use it!
step 1 move the pool.ini file to /etc/ and modify it as you need.
step 2 start the pool_server process: ./pool_server start support
"start" "stop" "restart" "reload"
step 3 modify you php script:
<?php
$db = new PDO(xxxxx);
=> $db = new pdo_connect_pool(xxxx);//dont use persistent
$redis = new Redis();
=》$redis = new redis_connect_pool();//dont use pconnect
tips:use $db/$redis->release() to release the connection as early as you can;
?>
The code on github
github.com/swoole/php-connect-pool