web框架并发5--japronto

2019-01-22  本文已影响0人  流亡民头

 由于机器是python2.7, 但正好有docker环境, 就直接用docker的方式体验传说的120万并发架构

一、环境

1. docker pull japronto/japronto

二、代码(test_japronto.py)

# examples/1_hello/hello.py

from japronto import Application

# Views handle logic, take request as a parameter and

# returns Response object back to the client

def hello(request):

    return request.Response(text='Hello world!')

# The Application instance is a fundamental concept.

# It is a parent to all the resources and all the settings

# can be tweaked here.

app = Application()

# The Router instance lets you register your handlers and execute

# them depending on the url path and methods

app.router.add_route('/', hello)

# Finally start our server and handle requests until termination is

# requested. Enabling debug lets you see request logs and stack traces.

app.run(debug=True)

三、启动web服务命令

docker run -p 8080:8080 -v $(pwd)/test_japronto.py:/test_japronto.py japronto/japronto --script /test_japronto.py

四、测试结果

1. webbench -c 1 -t 10 http://127.0.0.1:8080/

Speed=254358 pages/min, 390015 bytes/sec.

Requests: 42393 susceed, 0 failed.

2.webbench -c 10 -t 10 http://127.0.0.1:8080/

Speed=694422 pages/min, 1064798 bytes/sec.

Requests: 115737 susceed, 0 failed.

3. webbench -c 20 -t 10 http://127.0.0.1:8080/

Speed=710580 pages/min, 1089565 bytes/sec.

Requests: 118430 susceed, 0 failed.

由2和3的结果可知, 客户端数量的增加, 并发能力并无明显增加。

上一篇 下一篇

猜你喜欢

热点阅读