Pergunta

I'm pretty new to web development. Lately I have been making a site using Django. I was very interested in implementing websockets in the site. To achieve this I was using django-socketio (available on git hub at https://github.com/stephenmcd/django-socketio). All this was working fine using gevent's pywsgi server which is suggested in the django-socketio documents.

From reading some books on django it seems that it is recommend to use Django with Apache and mod_python for deployment. At the moment I am unsure of the best way to go about bringing Django, Apache and websockets together. Should I be using the pywsgi server to handle the django-socketio sockets running along side apache to serve the rest of the project? Is there a way in which Apache can handle everything? Should I just not use Django-Socketio? I would really like to use Django and Apache because I know a little about them. Which is a lot more than I know about anything else :D

Anyway my question is really if anybody knows any good articles or documentation on using Django-socketio and Apache so I can get my head around the topic?

Thank you.

Foi útil?

Solução

To start with, anything you read suggesting mod_python is highly out-dated. It's no longer developed and mod_wsgi is the right approach when using Apache.

As far as I'm aware, mod_wsgi doesn't support the type of open connections required by WebSockets. A quick search on Google shows that there are ways to get WebSockets working under Apache, but as to how well that would work with the gevent/django-socketio stack is something you'd need to look into.

I would suggest using gevent's server as I recommended in the django-socketio docs, for handling the WebSocket connections. Benchmarks should be taken with a grain of salt, but if you take a look at these results you'll find gevent to be on par with mod_wsgi.

django-socketio provides the convenience of letting you serve the WebSocket connections as well as regular Django views through a single application instance. If that doesn't suit you, you could implement these as separate projects, and run the regular Django part under Apache/mod_wsgi.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top