终于决定废弃java而使用python来开发网站,测试web.py的性能有点失望,看到bottle性能不错,也满足我们的需求,符合python simple的理念。测试一下生产环境的性能。
参照
http://studio.zeuik.com/?p=791
测试机器:X5650X2,48G内存,centos6,包括nginx,uwsgi
压测机器:X5680X2,96G内存
web.py把cpu几乎用尽的情况下也就5000req/s左右。
1、获取安装文件
nginx-1.0.10.tar.gz
uwsgi-0.9.9.2.tar.gz
virtualenv-1.6.4.tar.gz
bottle-0.10.1.tar.gz
2、安装nginx
tar zxvf nginx-1.0.10.tar.gz
cd nginx-1.0.10
./configure --prefix=/usr/local/nginx --with-select_module --with-poll_module --with-http_ssl_module --with-http_gzip_static_module --with-http_flv_module --with-http_sub_module --with-http_stub_status_module --with-http_secure_link_module
make && make install
配置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 index; # 对应index.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
tar zxvf uwsgi-0.9.9.2.tar.gz
cd uwsgi-0.9.9.2
mkdir /usr/local/uwsgi
cp uwsgi /usr/local/uwsgi/
cp uwsgi.xml /usr/local/uwsgi/bottletest.xml
chown root:wheel /usr/local/uwsgi/logs
配置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 (index)]</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、安装virtualenv并创建bottletest应用
tar zxvf virtualenv-1.6.4.tar.gz
cd virtualenv-1.6.4
python setup.py install
/usr/bin/virtualenv /application/venv/bottletest
cd /application/venv/bottletest
source bin/activate
5、编辑python文件
/application/venv/bottletest/index.py
from bottle import route, run, default_app
@route('/')
def index():
return "hello world"
if __name__ == "__main__":
run(host="localhost", port=8888)
else:
application = default_app()
6、启动nginx和uwsgi
/usr/local/nginx/sbin/nginx
/usr/local/uwsgi/uwsgi -x /usr/local/uwsgi/bottletest.xml
7、ab测试结果
100 client
ab -c 100 -n 100000 http://192.168.0.90/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.0.90 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
Server Software: nginx/1.0.10
Server Hostname: 192.168.0.90
Server Port: 80
Document Path: /
Document Length: 11 bytes
Concurrency Level: 100
Time taken for tests: 4.891 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 16800336 bytes
HTML transferred: 1100022 bytes
Requests per second: 20443.76 [#/sec] (mean)
Time per request: 4.891 [ms] (mean)
Time per request: 0.049 [ms] (mean, across all concurrent requests)
Transfer rate: 3354.12 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.7 1 15
Processing: 1 4 1.8 4 134
Waiting: 1 4 1.9 4 134
Total: 1 5 1.8 5 135
Percentage of the requests served within a certain time (ms)
50% 5
66% 5
75% 5
80% 5
90% 6
95% 6
98% 8
99% 13
100% 135 (longest request)
1000 client
ab -c 1000 -n 100000 http://192.168.0.90/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.0.90 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
Server Software: nginx/1.0.10
Server Hostname: 192.168.0.90
Server Port: 80
Document Path: /
Document Length: 11 bytes
Concurrency Level: 1000
Time taken for tests: 9.057 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 16800000 bytes
HTML transferred: 1100000 bytes
Requests per second: 11040.71 [#/sec] (mean)
Time per request: 90.574 [ms] (mean)
Time per request: 0.091 [ms] (mean, across all concurrent requests)
Transfer rate: 1811.37 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 9 114.9 4 3007
Processing: 1 51 372.0 12 9028
Waiting: 0 50 372.1 10 9028
Total: 3 60 389.4 16 9043
Percentage of the requests served within a certain time (ms)
50% 16
66% 19
75% 21
80% 22
90% 26
95% 31
98% 50
99% 3006
100% 9043 (longest request)
webbench模拟1000和5000客户端测试,系统负载都在4左右
1000 client
./webbench -t 30 -c 1000 http://192.168.0.90/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.0.90/
1000 clients, running 30 sec.
Speed=1195526 pages/min, 3347411 bytes/sec.
Requests: 597753 susceed, 10 failed.
5000 client
./webbench -t 30 -c 5000 http://192.168.0.90/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.0.90/
5000 clients, running 30 sec.
Speed=1209354 pages/min, 3383884 bytes/sec.
Requests: 604269 susceed, 408 failed.
总结
性能基本满意,回头测试一下模板cheetah和mako的性能。
再测试一下nginx upstreaming tornado的性能,看是否能作为nginx c module某些功能的替代品
分享到:
相关推荐
当我们在用django开发的web项目时,开发测试过程中用到的是django自带的测试服务器,由于其安全及稳定等性能方面的局限性,django官方并不建议将测试服务器用在实际生产。 nginx+uwsgi+django是我们常用的django...
基于Linux centOS通过nginx与uwsgi离线部署django项目所需要的资源。
centos7.6离线安装nginx
Ubuntu12.04 nginx python uwsgi Django安装步骤
非root下,离线安装nginx依赖加nginx安装包,需要先装gcc-c++
Linux系统下安装nginx-1.14.1所需的所有包 以及rpm依赖包,安装文档 https://blog.csdn.net/weixin_41851100/article/details/89565198
nginx作为一款服务器,在反向代理、负载均衡等方面具有优秀的性能,但是在深入学习之前需要先安装nginx。这里记录一下自己在centos7操作系统下安装nginx的过程,以便之后学习时查阅。笔者这里的Linux服务器使用的是...
主要介绍了Python系列之-Nginx+uWSGI+virtualenv多项目部署教程,本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
Centos+Django+Uwsgi+Nginx(所有软件包,包括rpm软件包和pip包)。uwsgi 2.0.19.1,Django3.1.2 ,Python3.6.5,mysql5.7,nginx1.18.0
Nginx+Uwsgi+Django(python3)+Vue部署,一步步实现。网上找了N多篇文章都没成功,特意记录,以免其他同学踩坑
详细介绍python+django+nginx+uwsgi配置过程,1. Apache: 世界使用排名第一的Web服务器 2. Nginx: 轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器 3. nginx 做为代理服务器:负责静态资源...
要创建镜像docker-django-nginx-uwsgi-centos7/django ,请在docker-django-nginx-uwsgi-centos7/django -django-nginx-uwsgi-centos7 文件夹中执行以下命令: docker build -t docker-django-nginx-uwsgi-centos7...
nginx_在centos环境编译安装
nginx-1.4.5-1.el6.ngx.x86_64.rpm nginx rpm安装包-centos6亲测可用 无需额外依赖 配置目录:/etc/nginx /etc/nginx/conf.d
YUM upgrade升级:本方式适用于使用rpm安装nginx的方式,优点是升级操作简单便捷,缺点是无法升级到指定版本,默认升级至YUM安装支持的最新版本,当前最新版本为nginx1.18.0。 源码平滑升级升级:本方式适用于...
Centos+Nginx+UWSGI+Django搭建高性能WEB服务器 很不错的资料,需要的可以下载看看
Centos6.X安装Nginx教程 https://mp.csdn.net/postedit/51086111
在centos系统下,使用Nginx反向代理和uWsgi服务器部署Python Flask项目,这里记录了我配置的整个过程,亲测可用
yum 安装 Nginx 为懒人准备。 第三方yum源(CentOS默认的标准源里没有nginx软件包)
centos7下在有网络和没网络的情况安装nginx;