在使用Redis服务器(v4.x)的实际生产负载(web )中,当使用worker_class gevent时,查询时间增加了3。数据库访问也越来越差(但不是很大,只有50%)。我想弄清楚为什么会发生这种事。有什么想法吗?这个应用程序是非常IO绑定的,对每一个请求都有大量的数据库查询和redis访问,这应该是gevent的完美场景。
从同步到GEVENT (上午11点)

猴子在插座上的补丁会以某种方式降低性能吗?我试图微调worker_connections,但没有成功,即使是极低的2级(几乎再次同步),也给了我同样的坏结果。我是不是错过了一些关于gevent和它的伪路径如何工作的问题?
免责声明:我使用NewRelic来监视性能和redis-py/django/mysql。我尝试了一些调整,比如对Redis使用BlockingConnectionPool,但是我的数据库访问性能也降低了,所以Redis不是唯一的问题。工作人员大小为5(CPU*2+ 1)。我还随机使用了大量的GreenletExit/ConnectionErrorredis,通过将worker_connections从2k (默认)移动到10来最小化。
发布于 2019-05-29 16:59:57
猴击后的红线连接的例子。
_rconn = None
def redisconn():
    global _rconn
    if _rconn is None:
        try:
            _rconn = redis.StrictRedis(host=redisconfig['host'], port=redisconfig['port'], db=redisconfig['db'])
        except:
            traceback.print_exc()
            _rconn = None
    return _rconn
class RedisCache(object):
    def __init__(self):
        #in case of a lost connection lets sit and wait till it's online
        global _rconn
        if not _rconn:
            while not _rconn:
                try:
                    redisconn()
                except:
                    print('Attempting Connection To Redis...')
                    gsleep(1)
        self.r = _rconn
        self.rpool = self.r.connection_pool
    def get(self, key):
        return self.r.get(key)
    def set(self, key, meta, expire=86400, nx=True):
        return self.r.set(key, json.loads(meta), ex=expire, nx=nx)
    def connections(self):
        return self.rpool._created_connections
    def inuse(self):
        return self.rpool._in_use_connectionshttps://stackoverflow.com/questions/56350194
复制相似问题