问题
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