简体   繁体   中英

Python: 100 connections to MongoDB cause a high cpu usage, Why?

MongoEngine support connect to multi mongodb databases.

I write this simple code that make 100 connections to mongodb from python script

在此处输入图片说明

But, I noticed in the top , Python cause a very high CPU usage

在此处输入图片说明

My CPU:

在此处输入图片说明

Why this ?

And If i wanna connect to multi mongodb database in python, How to do it correctly ?

I wrote an equivalent script using pymongo, and the DB CPU usage stayed at 0 even with 300+ connections open.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM