如何在2个不同的PHP进程之间共享MySQL连接 [英] How to Share a MySQL connection between 2 different PHP Processes

查看:167
本文介绍了如何在2个不同的PHP进程之间共享MySQL连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不寻常的情况,我的网站通过沙箱运行两个完全不同的PHP进程.我有一个正常的网站通过fastcgi运行,中间是fastcgi进程通过cli执行一个沙盒脚本.这两个进程都需要一个MySQL连接,我想知道是否有一种共享该连接的方法,因为当沙盒脚本运行时,fastcgi只是在等待它完成,因此不会并发.

I have an unusual case, my website runs two totally different PHP process through a sandbox. I have the normal website running through fastcgi and in the middle that fastcgi process executes one sandboxed script through cli. Both those processes require a MySQL connection and I was wandering if there is a way to share that connection since when the sandboxed script is running the fastcgi is just waiting for it to finish so there would be no concurrency.

这将极大地提高我的硬件能力,因为每个客户端仅需要一个MySQL连接,这与我目前需要的两个连接不同.

This would greatly improve my hardware capability since I would only need one MySQL connection per client unlike the two connections that I need at the moment.

我总是可以为这种效果编写某种多路复用代理的代码,但是是否有运行Mill的解决方案?我会很感激.

I could always code some kind of multiplexing proxy for this effect but is there any run of the mill solution? I would really appreciate.

致谢.

推荐答案

使用数据库连接池中间件或代理

use database connection pooling middleware or proxy

sqlrelay

mysql-proxy

代理

这篇关于如何在2个不同的PHP进程之间共享MySQL连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆