简体   繁体   English

在IBM Cloud上为Python Cloud Foundry应用程序调整DB2 keepalive设置

[英]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: 一些事情:

  • The problem is hard to replicate 问题很难重现
  • The app works fine on localhost, but not when deployed 该应用程序可在localhost上正常运行,但在部署时无法正常运行
  • I do have other simultaneous CRUD operations happening, which may be potentially conflicting somehow. 我确实还有其他同时发生的CRUD操作,这些操作可能会以某种方式发生冲突。 There could be a race condition that somehow never happens on localhost. 可能存在某种竞争状况,无论如何都不会在localhost上发生。
  • My flask app is deployed using gunicorn , which was killing the worker thread after 30 seconds, so the DB connection terminated mid-query. 我的flask应用程序是使用gunicorn部署的,后者在30秒后杀死了工作线程,因此数据库连接在查询中终止。 I adjusted the timeout to 75 seconds, but then the query started returning in under 1 s. 我将超时时间调整为75秒,但随后查询开始在1秒内返回。

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.

相关问题 从 Python 笔记本更新 IBM DB2 云中的表 - Update Table in IBM DB2 Cloud from Python notebook 与 IBM Cloud 上的 Db2 的 SQLAlchemy 连接错误 - SQLAlchemy connection error with Db2 on IBM Cloud 使用 python api ibm_db 连接到 IBM DB2 on Cloud - Connect to IBM DB2 on Cloud using python api ibm_db Python Flask 作为 Cloud Foundry 应用程序与作为容器 - Python Flask as a Cloud Foundry app vs as a container IBM Cloud db2 django 迁移 python manage.py migrate - IBM Cloud db2 django migrations python manage.py migrate 在 Python Flask Cloud Foundry/IBM Cloud 应用程序中添加 Java/JRE/JVM - Add Java/JRE/JVM in Python Flask Cloud Foundry/IBM Cloud application 运行 python IBM Cloud Apps Cloud Foundry 时出现 ModuleNotFoundError 错误:没有名为“matplotlib”的模块 - Running python IBM Cloud Apps Cloud Foundry with error in ModuleNotFoundError: No module named 'matplotlib' Python和IBM DB2:UnicodeDecodeError - Python and IBM DB2: UnicodeDecodeError 如何解决 SQLAlchemy 连接问题:连接到 IBM Cloud 上托管的 IBM db2 服务器时,“需要 SQLAlchemy 格式的连接信息” - How to fix SQLAlchemy connection problem: 'Connection info needed in SQLAlchemy format' when connecting to IBM db2 server hosted on IBM Cloud 如何将 IBM cloudant 数据库连接到 IBM 云(云基础设施)上的 python 应用程序代码? - how to connect IBM cloudant database to python app code already on IBM cloud(cloud foundary)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM