纯python实现的web: tornado性能测试
来源:互联网 发布:美工刀架重型 编辑:程序博客网 时间:2024/06/04 23:27
测试环境:
服务器配置: 4 x Intel(R) Xeon(R) CPU E5405 @ 2.00GHz, 4G内存, 操作系统: CentOS 5.3 x86_64
nginx前端 + 4 tornado(0.2) web process
tornado: http://www.tornadoweb.org (已被墙)
测试场景:
http get请求,服务器端直接返回"hello world"
代码及nginx配置:
main.py:
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""web main"""
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import RequestHandler, Application, authenticated
#from rockps.auth import AuthHandler
class MainHandler(RequestHandler):
def get(self):
self.write("hello world")
settings = {
}
application = Application([
(r"/", MainHandler),
], **settings)
if __name__ == "__main__":
http_server = HTTPServer(application)
http_server.listen(8081)
IOLoop.instance().start()
# -*- coding: utf-8 -*-
"""web main"""
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import RequestHandler, Application, authenticated
#from rockps.auth import AuthHandler
class MainHandler(RequestHandler):
def get(self):
self.write("hello world")
settings = {
}
application = Application([
(r"/", MainHandler),
], **settings)
if __name__ == "__main__":
http_server = HTTPServer(application)
http_server.listen(8081)
IOLoop.instance().start()
nginx.conf:
user root;
worker_processes 1;
error_log /var/nginx_error.log;
pid /var/run/nginx.pid;
events {
worker_connections 51200;
use epoll;
}
http {
# Enumerate all the Tornado servers here
upstream frontends {
server 127.0.0.1:8081;
server 127.0.0.1:8082;
server 127.0.0.1:8083;
server 127.0.0.1:8084;
}
#include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access22.log;
keepalive_timeout 65;
proxy_read_timeout 200;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/html text/css text/xml
application/x-javascript application/xml
application/atom+xml text/javascript;
# Only retry if there was a communication error, not a timeout
# on the Tornado server (to avoid propagating "queries of death"
# to all frontends)
proxy_next_upstream error;
server {
listen 8085;
# Allow file uploads
client_max_body_size 50M;
location ^~ /static/ {
root /var/www;
if ($query_string) {
expires max;
}
}
location = /favicon.ico {
rewrite (.*) /static/favicon.ico;
}
location = /robots.txt {
rewrite (.*) /static/robots.txt;
}
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://frontends;
}
}
}
worker_processes 1;
error_log /var/nginx_error.log;
pid /var/run/nginx.pid;
events {
worker_connections 51200;
use epoll;
}
http {
# Enumerate all the Tornado servers here
upstream frontends {
server 127.0.0.1:8081;
server 127.0.0.1:8082;
server 127.0.0.1:8083;
server 127.0.0.1:8084;
}
#include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access22.log;
keepalive_timeout 65;
proxy_read_timeout 200;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/html text/css text/xml
application/x-javascript application/xml
application/atom+xml text/javascript;
# Only retry if there was a communication error, not a timeout
# on the Tornado server (to avoid propagating "queries of death"
# to all frontends)
proxy_next_upstream error;
server {
listen 8085;
# Allow file uploads
client_max_body_size 50M;
location ^~ /static/ {
root /var/www;
if ($query_string) {
expires max;
}
}
location = /favicon.ico {
rewrite (.*) /static/favicon.ico;
}
location = /robots.txt {
rewrite (.*) /static/robots.txt;
}
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://frontends;
}
}
}
测试结果:
点击率可以超过7000,但后面再加用户开始往下掉,请求开始出错,最合适的时候大概3500个用户
持续运行后,连接数稳在1万。
结论,2个字:
牛X
【原文:http://www.cnblogs.com/fengmk2/archive/2009/10/28/tornado-test.html】
0 0
- 纯python实现的web: tornado性能测试
- 纯python实现的web: tornado性能测试
- 纯python实现的web: tornado性能测试以及实际使用解析
- python常用web框架性能测试(django,flask,bottle,tornado)
- [Python--]tornado.web.StaticFileHandler 实现文件下载
- tornado性能测试
- Python的tornado框架性能研究
- Python:FriendFeed的Tornado Web Server
- Python:FriendFeed的Tornado Web Server
- 非阻塞的Python web框架tornado
- python web 框架tornado-4.4.2 安装测试
- nginx+tornado与nginx+go的性能测试
- Python web框架:Django & Tornado
- Python web框架:Django & Tornado
- python tornado web开发环境
- Python语言写成的Web服务器 Tornado 简介
- python WEB tornado框架与mako模板的结合
- web简单应用python框架的选择-tornado
- Android查看sqlite数据库内容的方法
- LeetCode Palindrome Linked List
- android apk 防止反编译技术第五篇-完整性校验
- Android Studio 中Gradle配置debug使用release的签名
- linux 系统下查找多个文件包含特定关键字 查询
- 纯python实现的web: tornado性能测试
- 从我一年编程生涯中得到的经验教训
- SOAPUI测试WSDL项目(一)---创建WSDL项目
- Cocos2dx引擎笔记——数据结构
- [leetcode-174]Dungeon Game(java)
- 网龙2010年笔试题
- iOS项目开发实战——获取本机IP地址
- PHP Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY
- HDU 1729 Stone Game(SG函数变形)