webbench对nginx+web.py的hello.py测试

1,访问效果

curl http://127.0.0.1:8000/hello
Hello World!d

curl http://python.i-david.org/hello
Hello World!d


2,基本部署
启动脚本

#!/bin/sh

ps -aux | grep 8000 | grep -v "grep" | awk '{print $2}' | xargs kill
python /home/david/python/test002/hello.py 127.0.0.1:8000 >/dev/null 2>&1 &

exit 0


nginx配置

server {
listen 80;
server_name python.i-david.org;

location / {
proxy_pass http://127.0.0.1:8000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Remote-Host $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}


hello.py

#!/usr/bin/python
# filename:hello.py
# -*- coding: UTF-8 -*-

import web

urls = ("/.*", "hello")
app = web.application(urls, globals())

class hello:
def GET(self):
return "Hello World!"

if __name__ == '__main__':
app.run()



3,测试效果
测试I http://127.0.0.1:8000/hello

webbench -c 100 -t 10 http://127.0.0.1:8000/hello
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://127.0.0.1:8000/hello
100 clients, running 10 sec.

Speed=14772 pages/min, 21434 bytes/sec.
Requests: 2462 susceed, 0 failed.



测试II http://python.i-david.org/hello

webbench -c 100 -t 10 http://python.i-david.org/hello
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://python.i-david.org/hello
100 clients, running 10 sec.

Speed=16128 pages/min, 29990 bytes/sec.
Requests: 2688 susceed, 0 failed.



测试I是直接通过web.py框架访问hello.py程序的压力测试结果
测试II是通过nginx代理访问hello.py程序的压力测试结果
测试II在速度,吞吐率,请求成功数上都比直接访问要好
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值