Thursday, March 28, 2013

Nginx upload module vs Flask

Env

Ubuntu 12.04 32bit
Nginx 1.1.19 (HTTP server)

Flask 0.9 (light python framework)
Gevent: 1.0rc2 (coroutine I/O)
Gunicorn 0.17.2 (WSGI server)

Nginx setting

Nginx listen to port 8666
serves requests to URL /upload
and also work as a reverse proxy to Flask which serve requests on port 8222

Server code

server application run in 5 worker mode with Gunicorn + Gevent
gunicorn -k gevent -b 0.0.0.0:8222 -w 5 t:app


Test code

start N threads, and upload file to the URL




Result


Performance test result:
Unit: seconds
file size: 3.3 MB
concurrent number
Flask 0.9 + gevent 1.0rc2 + gunicorn 0.17.2 + Nginx
(5 worker processes)
Nginx + Nginx upload module
50
6.029
2.328
100
12.788
4.995
200
28.828
10.813


As we expected, Nginx upload module which written in C, is about twice faster than pure python code while processing file uploading.


No comments:

Post a Comment