WSGI 服务器

Meinheld 详细介绍

Meinheld 是一个高性能的异步 WSGI Web 服务器。是一个兼容 WSGI 的服务器,支持 PEP333 和 PEP3333 规范。Meinheld 利用 greenlet 和 Picoev 实现异步 I/O。

Meinheld 要求 Python 2.x >= 2.6 或者 Python 3.x >= 3.2 ,同时要求 greenlet >= 0.4.5。支持 Linux, FreeBSD, Mac OS X. 也可以通过 Gunicorn 来提供服务。

示例代码:

from meinheld import server
 
def hello_world(environ, start_response):
    status = '200 OK'
    res = "Hello world!"
    response_headers = [
        ('Content-type','text/plain'),
        ('Content-Length',str(len(res)))]
    start_response(status, response_headers)
    return [res]
 
server.listen(("0.0.0.0", 8000))
server.run(hello_world)

http://www.oschina.net/p/meinheld

 

流行 WSGI 服务器性能对比

 

最近对比了几款比较流行的WSGI服务器的性能,发现 uwsgi 最快,在这里和大家分享一下,请多指教

先上测试结果啦


参与对比的WSGI服务器
wsgiref https://docs.python.org/2/library/wsgiref.html
netius http://netius.hive.pt/
waitress http://docs.pylonsproject.org/projects/waitress/en/latest/
cherrypy http://docs.cherrypy.org/
gunicorn http://docs.gunicorn.org
uwsgi https://uwsgi-docs.readthedocs.io

测试环境
vagrant 启动两台虚拟机。虚拟机版本是 ubuntu/trusty64
55.55.55.5: 运行服务器
55.55.55.6: 运行测试

测试应用
为了只测试服务器性能,应用设计的很简单,只返回Testing
def app(environ, start_response):
    status = '200 OK'
    headers = [('Content-type', 'text/plain')]
    start_response(status, headers)
    return ['Testing.\n']

测试工具
Apache bench
http://httpd.apache.org/docs/2.4/programs/ab.html
测试命令
ab -n 500 -c 50 "http://55.55.55.5:8081/"

测试结果数据

Server

Requests per second

uwsgi

2500

waitress

1900

gunicorn

1700

netius

1660

cherrypy

600

wsgiref

18


测试代码
https://github.com/zhuyi10/wsgi_performance

请各位多指教啊!

 

服务器流行

本主题由 blueelwang 于 2016-11-13 11:01 审核通过

results.png (22.96 KB, 下载次数: 12)

 

测试结果

测试结果

转载于:https://my.oschina.net/mickelfeng/blog/857464

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值