I am trying to run a simple NGnix + Gunicorn + Django + MySQL (RDS on AWS) stack, but obviously anything happening to some MySQL query will slow down and lock down the service.
To prevent that, I started using eventlet (which also plays nice with Celery), but patching MySQLdb seems to result in performance loss (2-3x response time) and instability (may lock down all db connection for a few seconds during restart).
Celery + eventlet with the same logic seem to work just fine, so what am I missing?
try:
import eventlet
worker_class = 'egg:gunicorn#eventlet'
worker_connections = 1000
def do_post_fork(server, worker):
eventlet.monkey_patch()
eventlet.monkey_patch(MySQLdb=True)
post_fork = do_post_fork
except ImportError as e:
import logging
logging.exception(e)
pass
Thanks!