nginx,uwsgi,bottle,mako安装和性能测试
上一篇 nginx,uwsgi,bottle,virtualenv在centos6上安装及性能测试 测试了nginx,uwsgi和bottle的性能
这篇继续测试一下mako模板性能
1、安装mako
tar -zvxf Mako-0.5.0.tar.gz cd Mako-0.5.0python setup.py install
worker_processes 8; #24线程cpu,8个nginx,16个uwsgievents { worker_connections 10240;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; charset utf-8; root /application/venv/bottletest; server_name cow.com; location / { include uwsgi_params; uwsgi_param UWSGI_PYHOME /application/venv/bottletest; uwsgi_param UWSGI_CHDIR /application/venv/bottletest; uwsgi_param UWSGI_SCRIPT hello; # 对应hello.py uwsgi_pass 127.0.0.1:8888; } location ^~ /static { root /application/venv/bottletest; access_log off; } location /status { stub_status on; access_log off; } } } <uwsgi> <socket>127.0.0.1:8888</socket> <home>/application/venv/bottletest</home> <chdir>/application/venv/bottletest</chdir> <python-path>/application/venv/bottletest</python-path> <module>[WSGI Script (hello)]</module> <limit-as>256MB</limit-as> <processes>16</processes> <!-- 进程数 --> <master/> <memory/> <logto>/usr/local/uwsgi/logs/bottletest.log</logto> <daemonize>/var/log/uwsgi.log</daemonize> <max-requests>10000</max-requests></uwsgi>
from bottle import route, run, mako_view, default_app@route('/hello/template/:names')@mako_view('hello.html')def template_hello(names): names = names.split(',') return dict(title='Hello World', names=names)if __name__ == "__main__": run(host="192.168.0.90", port=8080)else: application = default_app()<html> <head> <title>${title}</title> </head> <body> %for name in names: <p>Hello, <strong>${name}</strong></p> %endfor </body></html>/usr/local/nginx/sbin/nginx/usr/local/uwsgi/uwsgi -x /usr/local/uwsgi/bottletest.xml
lynx --source http://192.168.0.90/hello/template/123,234,2343,21,adead,sa2221<html> <head> <title>Hello World</title> </head> <body> <p>Hello, <strong>123</strong></p> <p>Hello, <strong>234</strong></p> <p>Hello, <strong>2343</strong></p> <p>Hello, <strong>21</strong></p> <p>Hello, <strong>adead</strong></p> <p>Hello, <strong>sa2221</strong></p> </body></html>
./webbench -t 30 -c 1000 'http://192.168.0.90/hello/template/123,234'Webbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.Benchmarking: GET http://192.168.0.90/hello/template/123,2341000 clients, running 30 sec.Speed=1202950 pages/min, 6295417 bytes/sec.Requests: 601473 susceed, 2 failed.
./webbench -t 30 -c 5000 'http://192.168.0.90/hello/template/123,234' Webbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.Benchmarking: GET http://192.168.0.90/hello/template/123,2345000 clients, running 30 sec.Speed=1313490 pages/min, 6872361 bytes/sec.Requests: 656595 susceed, 150 failed.