You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
语言:python3.11,flask2.0,Gunicorn==20.0.4
系统:linux、macos
现象:当用命令gunicorn --preload.... 启动flask后,workers = 2,并发调用50次测试接口,接口内部逻辑只有一句sql是 select id from table where id=123
理论结果:应该是50次全部都是一样的查询结果;
实际结果:其中总会有1-2次出现mysql查询的结果为空,是怎么回事?mysql是flask启动后在init文件中做的连接池对象的初始化,应该会被全局共享。当我worker改为1,问题消失,或者当我去除preload参数,保证每个子进程都有各自变量时,问题也会消失,所以看起来问题像是因为共享了全局mysql连接池对象而导致的问题,具体gunicorn内部是什么原因导致的,有朋友知道吗?
The text was updated successfully, but these errors were encountered:
语言:python3.11,flask2.0,Gunicorn==20.0.4
系统:linux、macos
现象:当用命令gunicorn --preload.... 启动flask后,workers = 2,并发调用50次测试接口,接口内部逻辑只有一句sql是 select id from table where id=123
理论结果:应该是50次全部都是一样的查询结果;
实际结果:其中总会有1-2次出现mysql查询的结果为空,是怎么回事?mysql是flask启动后在init文件中做的连接池对象的初始化,应该会被全局共享。当我worker改为1,问题消失,或者当我去除preload参数,保证每个子进程都有各自变量时,问题也会消失,所以看起来问题像是因为共享了全局mysql连接池对象而导致的问题,具体gunicorn内部是什么原因导致的,有朋友知道吗?
The text was updated successfully, but these errors were encountered: