Because changed Nginx no longer use MOD_WSGI to run web.py application, now use is GEVENT-WSGI, the effect is not bad. But still want to try something else, such as the legendary super fierce Meinheld or something. Hardware and Software Environment
Hardware:
A 04 early acquisition of IBM X235 Server, CPU for Xeon 2.4G Two, memory 1g,100m network card.
Software:
Ubuntu Server 10.04 LTS
Apache 2.2.14
Nginx 0.7.65
Python 2.6.5
web.py 0.37
Mako 0.7.2
SQLAlchemy 0.7.8
Gevent 0.13.7
Gunicorn 0.14.6
Meinheld 0.4.15 Test Code
There are five versions, respectively:
The most basic Wsgi HelloWorld
def application (environ, start_response):
status = ' OK '
resp = "Hello world!"
Resp_headers = [(' Content-type ', ' text/plain;charset=utf-8 ')]
start_response (status, Resp_headers) return
[ Resp
The most basic web.py your IP
Class Yourip:
def get (self): return
' Your IP is:%s '% Web.ctx.ip
The web.py with the Mako template
Class Onlymako (Basehandler):
@expose ("Yourip")
def get (self): return
dict (YOURIP=WEB.CTX.IP)
web.py with a database
Class Onlydb:
def get (self):
created = web.ctx.provider.once_access (WEB.CTX.IP) return "for you
have logged:% S "% created
And the web.py--of database and Mako templates, which is the closest thing to a practical application.
Class Makodb (Basehandler):
@expose ("index")
def get (self):
created = web.ctx.provider.once_access ( WEB.CTX.IP) return
dict (created=created)
Test Target
Five types of operating environments:
web.py test Environment App.run
Web.py+gevent-wsgi
Gunicorn Default (Sync)
Gunicorn+gevent
Gunicorn+meinheld
Gunicorn using the-w 4 parameter, this parameter does not effectively increase the RPS, but it can reduce the failure rate to some extent in the case of high concurrency test. Test Mode
Apachebench 2.3 (Ubuntu Desktop 12.04)
The RPS test parameter is-n 200-c 22 measured five times RPS average.
The reason to use this relatively small parameter is because it is higher, and some of these tests will not pass. Test Results
RPS Test |
WSGI HelloWorld |
web.py Yourip |
Web.py+mako |
web.py +sqlalchemy (SQLite) |
Web.py+mako +sqlalchemy (SQLite) |
web.py +sqlalchemy (Postgresql) |
Web.py+mako +sqlalchemy (Postgresql) |
web.py App.run |
No |
130 |
93 |
75* |
45* |
59 |
40 |
Web.py+gevent |
No |
422 |
130 |
82 |
54 |
74 |
53 |
Gunicorn Default |
854 |
439 |
136 |
93 |
66 |
90 |
62 |
Gunicorn+gevent |
695 |
291 |
115 |
74 |
56 |
78 |
56 |
Gunicorn+meinheld |
3565 |
682 |
160 |
84 |
65 |
98 |
64 |
The number with "*" in it has a database error and is for informational purposes only.
In addition, with the same parameters measured Apache2 processing of static files RPS: 1780,nginx: 2951.
= = = Additional Split line = = =
Append a partial test result on my Atom small server:
The RPS of nginx processing static files is: 4000 or so.
WSGI Hello World test: Gunicorn+meinheld is about: 3800. Gunicorn+gevent is about: 1100. Gunicorn default is about: 1400.
Your IP test: Gunicorn+meinheld is about: 1000. Gunicorn+gevent is about: 450. Gunicorn default is about: 700.
In contrast, this atom small machine is much more fierce than the IBM server. The hardware is growing fast.
With hardware and software environment:
Atom D525 1.6G Dual core, 2gram,freebsd 9,nginx 1.2.2,python 2.7.3, other IBM servers.
And on this atom machine, the-w parameter has a significant contribution to RPS ... It seems that the problem with the old server is not obvious, but is not sure whether it is a hardware problem or OS problem. Conclusions
Meinheld is really fierce, processing the simplest WSGI than Apache2 processing static file is one times, with Nginx is quite even stronger.
App.run's RPS is much better than expected, only the concurrent number is not good, the-c parameter slightly increase will appear a lot of failure test.
Gevent is good enough, but it's a bit unscientific to be slower than Gunicorn's sync mode.
The advantage of Gunicorn is that it is easy to manage, and can be flexible to use a variety of work_class, particularly strange that the sync mode is also so fast.
The performance impact of web.py is still obvious.
The impact of the template is also obvious--mako is already a quick template, I really do not know how to use those kid slow template will be what effect.
The impact of the database is even greater, but pgsql performance can be similar to SQLite, really do not know is sqlite too slow or pgsql too fast ...
Originally a while ago I just heard openresty this goods when still very interested, but now see Meinheld performance later, feel or forget it, after all, with Openresty also to learn lua ... There are so many things to learn now that things that can be done with Python don't bother Lua.