[英]Python: 100 connections to MongoDB cause a high cpu usage, Why?
MongoEngine support connect to multi mongodb databases. MongoEngine支持连接到多个mongodb数据库。
I write this simple code that make 100 connections to mongodb from python script 我写了这个简单的代码,从python脚本到mongodb建立了100条连接
But, I noticed in the top
, Python cause a very high CPU usage 但是,我在最
top
注意到,Python会导致很高的CPU使用率
My CPU: 我的CPU:
Why this ? 为什么这个 ?
And If i wanna connect to multi mongodb database in python, How to do it correctly ? 如果我想在python中连接到多mongodb数据库,如何正确执行?
I wrote an equivalent script using pymongo, and the DB CPU usage stayed at 0 even with 300+ connections open. 我使用pymongo编写了一个等效的脚本,即使打开了300多个连接,DB CPU的使用也保持为0。
from pymongo import MongoClient
for x in xrange(100):
MongoClient()
Try it out and see if the problem persists? 试试看,看问题是否仍然存在? I believe that it's the officially supported Python package for MongoDB.
我相信这是MongoDB官方支持的Python软件包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.