[英]Adjust DB2 keepalive settings for a Python Cloud Foundry app on IBM Cloud
I have a working Python Cloud Foundry app on Bluemix / IBM Cloud that connects to, and otherwise works well with a DB2 on Cloud instance on Bluemix / IBM Cloud. 我在Bluemix / IBM Cloud上有一个可以正常工作的Python Cloud Foundry应用程序,该应用程序可以连接到Bluemix / IBM Cloud上的DB2 on Cloud实例,或者可以很好地与它一起使用。
However, after long intervals (I haven't been able to measure the time), the connection to DB2 closes, and my queries fail. 但是,经过很长的间隔(我无法测量时间)之后,与DB2的连接关闭,并且查询失败。 I could modify my code to check for this, but it would be great to be able to adjust the TCP keepalive settings.
我可以修改我的代码以进行检查,但是能够调整TCP Keepalive设置非常好。 Something along the lines of this .
与此类似的东西。
Would greatly appreciate any pointers. 将不胜感激任何指针。 I'm not sure how one adjusts the client-side settings on a Python Cloud Foundry app.
我不确定如何在Python Cloud Foundry应用程序上调整客户端设置。
Cheers. 干杯。
I tried reproducing this using a Python Flask Cloud Foundry app and a Db2 on Cloud Lite plan instance. 我尝试使用Python Flask Cloud Foundry应用程序和Cloud Lite计划实例上的Db2重现此内容。 My connections seem to stay alive for hours.
我的关系似乎可以存活几个小时。 It might be the python application you are running that has some kind of timeout.
您正在运行的python应用程序可能存在某种超时。
I could not find a satisfactory resolution. 我找不到令人满意的解决方案。 Like @jackic23 mentioned, there may be other factors at play.
就像提到的@ jackic23一样,可能还有其他因素在起作用。 Few things:
一些事情:
gunicorn
, which was killing the worker thread after 30 seconds, so the DB connection terminated mid-query. gunicorn
部署的,后者在30秒后杀死了工作线程,因此数据库连接在查询中终止。 I adjusted the timeout to 75 seconds, but then the query started returning in under 1 s. At this point, I have switched to an Enterprise DB2 plan, and the app is working fine. 此时,我已切换到Enterprise DB2计划,并且该应用程序运行正常。 To @jackic23's point, there may still be something else going on here (in my app's code) that may eventually need to be figured out.
就@ jackic23而言,这里可能仍然存在其他事情(在我的应用程序的代码中),最终可能需要弄清楚。
For now, I'm moving on. 现在,我继续前进。 Thank you @jackic23 for looking into this!
感谢@ jackic23对此进行调查!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.