上一篇
nginx,uwsgi,bottle,virtualenv在centos6上安装及性能测试 测试了nginx,uwsgi和bottle的性能
这篇继续测试一下mako模板性能
1、安装mako
tar -zvxf Mako-0.5.0.tar.gz
cd Mako-0.5.0
python setup.py install
2、修改上篇nginx配置文件
/usr/local/nginx/conf/nginx.conf
worker_processes 8; #24线程cpu,8个nginx,16个uwsgi
events {
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;
}
}
}
3、修改配置uwsgi的xml格式配置文件
/usr/local/uwsgi/bottletest.xml
<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>
4、编辑python文件
/application/venv/bottletest/hello.py
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()
5、编辑mako模板文件
/application/venv/bottletest/view/index.html
<html>
<head>
<title>${title}</title>
</head>
<body>
%for name in names:
<p>Hello, <strong>${name}</strong></p>
%endfor
</body>
</html>
6、启动nginx和uwsgi
/usr/local/nginx/sbin/nginx
/usr/local/uwsgi/uwsgi -x /usr/local/uwsgi/bottletest.xml
7、测试访问结果
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模拟1000客户端测试,系统负载在3-4之间
./webbench -t 30 -c 1000 'http://192.168.0.90/hello/template/123,234'
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.0.90/hello/template/123,234
1000 clients, running 30 sec.
Speed=1202950 pages/min, 6295417 bytes/sec.
Requests: 601473 susceed, 2 failed.
webbench模拟5000客户端测试,系统负载在4左右
./webbench -t 30 -c 5000 'http://192.168.0.90/hello/template/123,234'
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.0.90/hello/template/123,234
5000 clients, running 30 sec.
Speed=1313490 pages/min, 6872361 bytes/sec.
Requests: 656595 susceed, 150 failed.
总结
性能能够支持生产环境,cheetah的性能和mako差不多,但文档有些乱,且似乎不太活跃。
nginx+uwsgi+bottle+mako还是很不错的选择,由于数据库使用mongodb和redis,就不在测试ormapping的东西了。
分享到:
相关推荐
Ubuntu12.04 nginx python uwsgi Django安装步骤
Nginx+Uwsgi+Django(python3)+Vue部署,一步步实现。网上找了N多篇文章都没成功,特意记录,以免其他同学踩坑
详细介绍python+django+nginx+uwsgi配置过程,1. Apache: 世界使用排名第一的Web服务器 2. Nginx: 轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器 3. nginx 做为代理服务器:负责静态资源...
基于Linux centOS通过nginx与uwsgi离线部署django项目所需要的资源。
Centos+Nginx+UWSGI+Django搭建高性能WEB服务器 很不错的资料,需要的可以下载看看
五步教你实现使用Nginx+uWSGI+Django方法部署Django程序1
Nginx + uwsgi + web.py 搭建web服务器, 也包含一整套python服务器后台框架代码,简单方便,容易搭建。
nginx+uwsgi+mysql+python 环境详细搭建过程以及过程内出现问题分析。
当我们在用django开发的web项目时,开发测试过程中用到的是django自带的测试服务器,由于其安全及稳定等性能方面的局限性,django官方并不建议将测试服务器用在实际生产。 nginx+uwsgi+django是我们常用的django...
搭建Django web开发环境,使用Nginx和uwsgi的conf和ini文件。前提:nginx和uwsgi服务已经安装完成,且正常运行
nginx+uwsgi+python架构
nginx+uwsgi+django是我们常用的django部署方式。这篇文章主要介绍了nginx+uwsgi启动Django项目的详细步骤,非常具有实用价值,需要的朋友可以参考下
django+nginx+uwsgi服务器搭建手册
nginx+uwsgi部署步骤.md
在centos环境下部署nginx+django+uwsgi
适合在inux系统或者腾讯云使用docker部署项目,并且通过域名访问项目,技术有docker+nginx+uwsgi+conda+mysql+redis,小白也可以部署,步骤非常的详细,亲测有效,是我自己一步一步自己部署项目自己写的步骤,并且我...
自己通过nginx uwsgi 部署django项目,查询了很多资料,遇到了很多问题,最终完成了部署,趁着心情愉悦,写个随笔,为曾像我一样苦寻解决方案的小伙伴们提供些思路。 方法如下 安装Nginx: #安装nginx sudo apt-get...
实战Nginx(取代Apache的高性能Web服务器).pdf 实战Nginx(取代Apache的高性能Web服务器).pdf
使用nginx、uwsgi在cents7上布置flask
Centos+Django+Uwsgi+Nginx(所有软件包,包括rpm软件包和pip包)。uwsgi 2.0.19.1,Django3.1.2 ,Python3.6.5,mysql5.7,nginx1.18.0