I've setup my Python / Django app on a vmware machine with CentOS, uwsgi and gunicorn along with all my apps dependencies.
After running my app with gunicorn with the following command:
gunicorn --workers=4 --bind=0.0.0.0:8081 wsgi:application
The application works like a charm and everything is going smoothly. However, i tried running it with uwsgi to compare performance (requests / second) on both. So i ran the following command:
sudo uwsgi --chdir=/var/www/pyapp/ --module=wsgi:application --env DJANGO_SETTINGS_MODULE=settings --socket=127.0.0.1:8081 --processes=5 --harakiri=20 --max-requests=5000 --vacuum --master --pidfile=/tmp/pyapp-master.pid
The first problem i encountered running this is the following error:
invalid request block size: 21573 (max 4096)...skip
After adding the -b 25000 to make the buffer larger than the maxmimum, i started encountering:
timeout. skip request.
I couldn't suspect that my app had something wrong with it as it ran with gunicorn without such problems.
Can someone help pointing out what i am doing here?
Thanks
Best Answer
Adding --protocol=http solved the problem. By default uwsgi works with wsgi protocol which doesn't accept http requests.
In addition, instead of using the reverse proxy, you have to use uwsgi mode