runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Question: How do I create pools?

Open vrgenl opened this issue 2 years ago • 2 comments

So I have php-runtime working with swoole and symfony. Works like a charm! The only thing I cant seem to work out is to create pools for lets say SQL or Redis.

Previously I had created a command that runs a HttpServer and also spun up some workers for pools etc to keep connections open.

Can't seem to find any answers here in the issue history or anywhere else for that matter.

Kind regards, Rogier

vrgenl avatar Jan 27 '23 22:01 vrgenl

you can use, inspire by this lib: https://github.com/open-smf/connection-pool or if you want smth mature with sf app u can try https://github.com/pixelfederation/swoole-bundle and use worker events ... with lib above

pistej avatar May 23 '23 20:05 pistej

for doctrine you can use custom driver that already support connection pooling, then replace default dbal driver in symfony. Here is following dbal driver that already support connection pooling

  • https://github.com/diego-ninja/swoole-mysql-doctrine-driver/tree/main
  • https://github.com/opsway/doctrine-dbal-swoole-pgsql-driver/tree/main

and lastly you need to patch doctrine orm EntityManager to support long running process like this one https://github.com/opsway/doctrine-orm-swoole

for other connection pooling you can implement by hand using this https://github.com/swoole/library/blob/master/src/core/ConnectionPool.php

praswicaksono avatar Feb 03 '24 19:02 praswicaksono