0

I have a Django server, that also has a socketio compenent using python-socketio library. I'm trying to produce a relatively simple but production ready deployment for it on an Amazon EC2 Instance. I've successfully configured the NGINX proxy.

I'm curious about the best way to deploy, specifically with regard to WSGI.

I've tried using the raw eventlet WSGI server (eventlet.wsgi.server(eventlet.listen(("", 8000)), application)). I then start it with python manage.py runserver.

This has worked okay, but I'm unsure about how scalable it is.

It seems like the standard stack is Django + Gunicorn + NGINX. Based on python-socketio documentation, this should be possible. I tried django + eventlet + gunicorn, but it seems like gunicorn a) doesn't play nice with eventlet and b) only supports one worker. Gevent + Gunicorn doesn't have this bug, but still only supports one worker. Also, I'm not sure how actively maintained gevent is. So I'm not sure how scalable either Gunicorn + eventlet or Gunicorn + geventlet is as a WSGI server. So I'm not sure if Gunicorn is my best bet, or if it's too limited.

So TL;DR a) what scalable stack have you experienced success with for deploying Django + python-socketio and b) if it is still Django + gunicorn + NGINX, how should I configure my WSGI server to play well with Gunicorn.

  • Are you aware that the "one" eventlet or gevent worker implements concurrency that allows it to scale to hundreds/thousands of requests? Or that you are incorrect in that it is possible to use multiple workers with Socket.IO? I recommend you review the deployment section of the python-socketio documentation. The multi-worker option is complex (I'm not going to lie to you), but it is possible to do it. – Miguel Grinberg May 14 '23 at 19:29
  • Thanks Miguel, and thanks for maintaining the socketio documentation. I had reviewed the documentation, but out of the many potential options listed (i.e. eventlet, event, eventlet Gunicorn workers, etc.), I wasn't sure which one was suitable for my specific use case. I was also not aware of either of these facts you mention, hence the question :) Based on this response, it sounds Gunicorn would be unnecessary in this case and the eventlet WSGI server is suitable, since I will likely have less than 100 concurrent requests. Thank you! – Langston Nashold May 15 '23 at 21:54
  • That being said, @MiguelGrinberg I would be curious what your gut instinct would be when deploying a low to medium traffic app. Would you also use eventlet? – Langston Nashold May 16 '23 at 00:45
  • No. For low traffic I would use standard threads. – Miguel Grinberg May 16 '23 at 09:42

0 Answers0