3

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the heads up on mod_python. I was following a book called "The Definitive Guide to Django". I spent some time and looked into using Django, Apache, mod_wsgi and mod_pywebsocket (which uses mod_python). I got Django running under Apache/mod_wsgi and websockets running under Apache/mod_pywebsocket. But I found it quite hard to merge them together given my current level of programing. I will take your advice and go back to using gevent. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.