当下好多“王婆”卖瓜, 一个劲说架构并发能力 10万、100万, 但看到大家实际并发测试, 确少得可怜。
先说说tornado的并发能力
一、环境
1. python环境
Python 2.7.6
2. tornado环境
4.2.1
3. nginx环境
nginx version: nginx/1.9.9
4. 服务器和操作系统环境
物理双核、逻辑四十核, centos 7
二、tornado 单进程直接测试
1. 代码:
import tornado
import tornado.web
import tornado.httpserver
import sys, signal, time
def sig_handler(sig, frame):
tornado.ioloop.IOLoop.instance().add_callback(shutdown)
def shutdown():
HTTP_SERVER.stop()
io_loop = tornado.ioloop.IOLoop.instance()
io_loop.stop()
class MainHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
self.finish()
class Application(tornado.web.Application):
def __init__(self):
settings = dict(
debug=False,
)
handlers = [
(r"/", MainHandler),
]
super(Application,self).__init__(handlers,**settings)
def main():
global HTTP_SERVER
try:
HTTP_SERVER = tornado.httpserver.HTTPServer(Application())
HTTP_SERVER.listen(sys.argv[1])
except Exception, ex:
print "Create and listen http server failed! Exception: %s"% str(ex)
quit()
signal.signal(signal.SIGTERM, sig_handler)
signal.signal(signal.SIGINT, sig_handler)
tornado.ioloop.IOLoop.instance().start()
if __name__ == "__main__":
try:
main()
except Exception, ex:
print "Ocurred Exception: %s" % str(ex)
quit()
2. 执行命令
python server.py --port=40001
3. webbench 测试结果1(1251.4qps):
webbench -c 1 -t 10 http://127.0.0.1:40001/
Speed=75084 pages/min, 279062 bytes/sec.
Requests: 12514 susceed, 0 failed.
经过多次, 不同的客户端数量测试结果相差无几。