How to retrieve efficiently using Coubase Python Client Library?

泪湿孤枕 提交于 2019-12-08 07:29:26

问题


Action: I run the following code:

#Code to fetch a key from Couachbase serially again and again
from couchbase.client import Couchbase
couchbase = Couchbase("ubuntumartini03", "default", "")
bucket = couchbase["martini-tag-manager"]
while True:
    print bucket.get("somekey")

Result: Running this code I was able to make 500 ops per sec.

Action: I ran four instances of this code.

Result: I was able to make 2000 ops per sec.

Conclusion: Bottleneck is something else than max possible ops couchbase can entertain per sec OR max possible ops the given machine can make, for the above given code.

Question:

How to make max possible ops per sec by single instance itself?

回答1:


Couchbase Pytnon client is basically synchronous and doesn't leverage multiple cores that you probably have. It's trying to implement multi-threaded behavior but with CPython interpreter it's absolutely pointless. Only complete re-implementation using something like Gevent would help.

Also take a look at this bug.



来源:https://stackoverflow.com/questions/15089986/how-to-retrieve-efficiently-using-coubase-python-client-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!