使用 Celery 时打开的 mongoDB 连接过多
我正在使用 Celery 下载源并调整图像大小。然后使用 mongoengine 将提要和图像路径存储在 MongoDB 中。当我在运行任务后检查当前连接 (db.serverStatus()["connections"]) 时,我有 50-80 个“当前”连接,这些连接保持打开状态,直到我关闭 celeryd。有没有人遇到过这个问题和/或你知道我能做什么来解决它?
谢谢, 肯齐奇
I'm using Celery to download feeds and resize images. The feeds and image paths are then stored in MongoDB using mongoengine. When I check current connections (db.serverStatus()["connections"]) after running the tasks I have between 50-80 "current" connections, which remain open until I shutdown celeryd. Has anyone experienced this issue and/or do you know what I can do to solve it?
Thanks,
Kenzic
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这仅意味着 MongoDB 服务器有 50 到 80 个打开的连接,无需担心。 PyMongo(以及 MongoEngine)维护一个与 mongod 的内部连接池(即套接字),因此即使没有发生任何事情(没有活动的查询、命令等),连接仍然对以便下次使用时使用数据库。默认情况下,PyMongo 尝试为每个 Connection 对象保留不超过 10 个打开的连接。
您是否因打开的连接数而遇到任何特定问题?
This just means that there are between 50 and 80 connections open to the MongoDB server, and isn't cause for concern. PyMongo (and therefore MongoEngine) maintain an internal pool of connections (that is, sockets) to
mongod
, so even when nothing is happening (no active queries, commands, etc), the connections remain open to the database for the next time they will be used. By default, PyMongo attempts to retain no more than 10 open connections perConnection
object.Are you experiencing any specific problems due to the number of open connections?