如何使用Coubase Python客户端库高效检索? [英] How to retrieve efficiently using Coubase Python Client Library?

查看:159
本文介绍了如何使用Coubase Python客户端库高效检索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作:我运行以下代码:

#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")

结果:运行此代码,我能够每秒 500个操作 .

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

操作:我运行了此代码的四个实例.

Action: I ran four instances of this code.

结果:我能够实现 每秒2000次操作 .

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.

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

推荐答案

Couchbase Pytnon客户端基本上是同步的,不会利用您可能拥有的多个内核.它正在尝试实现多线程行为,但是使用CPython解释器绝对是没有意义的.只有使用Gevent之类的方法完全重新实现才有帮助.

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.

还请查看此错误.

这篇关于如何使用Coubase Python客户端库高效检索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆