dboss性能测试

之前自己写多线程测试dboss,性能很好,但在gunicron上面测试性能很差:

写道

[admin@server2 duitang]$ cat /duitang/logs/sys/gunicorn_7299.log |grep "memcache2" | awk '{print $4}' | grep -v "mem"|sort -rn| head -10
313.137054443
272.057771683
243.25299263
242.613077164
238.589048386
238.348960876
228.531122208
224.238157272
213.147163391
201.596021652
 

今天对dboss测试发现gevent对性能影响非常大,如果使用原始的gunicron,把worker_class = "gevent"注释掉之后,发现性能提升明显:

写道
[admin@server2 duitang]$ cat /duitang/logs/sys/gunicorn_7299.log |grep "memcache2" | awk '{print $4}' | grep -v "mem"|sort -rn| head -10
6.50000572205
6.25014305115
6.21294975281
5.72204589844
5.34701347351
5.24306297302
4.81510162354
4.68397140503
4.22811508179
4.22811508179

 

以为gevent的bug,升级到最新版本的gevent-0.13.8还是不行,最后想到使用原生的socket,修改为

import _socket  as socket,搞定。这是guniconr+gevent+java_memcached:

 

写道
[admin@server2 duitang]$ cat /duitang/logs/sys/gunicorn_7299.log |grep "memcache2" | awk '{print $4}' | grep -v "mem"|sort -rn| head -10
52.6340007782
50.5969524384
48.2759475708
45.1800823212
6.63900375366
6.30307197571
6.24895095825
6.09111785889
6.04200363159
6.00504875183
 


 

多线程测试脚本:

from django.core.management import setup_environ
import settings
setup_environ(settings)
from executor import Executor
from time import sleep
import sys
import memcache2
import memcache

#mc = memcache.Client(['127.0.0.1:11211'])
mc = memcache2.Client([])

class Checker():

    def __init__(self,key):
        self.key = key

    def run(self):
        mc.get(self.key)

executor = Executor(8000)
f  = open('memcache.log')
for fs in f.readlines():
    key = fs[0:len(fs)-1]
    executor.submit(Checker(key))
executor.join()

你可能感兴趣的:(性能测试)