Choosing a good asynchronous solution for Django projects

I am currently using Django for Apache (mod_wsgi) to develop my applications. One of my favorite things is "spoofing" asynchronous requests using JavaScript setInterval()

and AJAX to fetch new data from the database. For example:

// javascript

function someFunction() {
    // do some stuff
    setInterval(function() { fetchNewStuff() }, 1000); // run fetchNewStuff() every second
}

function fetchNewStuff() {
    Dajaxice.main.fetch_new_stuff(fetch_new_stuff_callback, {'id':$(this).attr('user_id')});
}

function fetch_new_stuff_callback(data){
    // append new stuff to my table, list or whatever in HTML page
}

      

As far as I know, this is fine for my needs. However, as my applications get bigger and more complex, it will eventually become too complex for both my server and my clients, no matter how much I try to minimize the data transported. Also, I cannot agree that in today's world I am still "faking" this :) So, I would like to find some "real" push-capable solution for my current and future projects.

I tried to solve my problem and I found many interesting things (Tornado, Nginx, Node.js, Twisted, etc.), but most of the tutorials / articles / blogs are at least 6 months old and I believe that at that time a lot has changed. So far I have tried to test Tornado and it was a successful test, but I am having trouble setting it up on my server. I've also tried Node.js, which is very simple since I know JavaScript very well, but again, I'm not sure if this is a good solution.

My question here is what would be the best (server, platform, infrastructure, whatever) to implement in my current and future applications, depending on these conditions:

  • easy to use (e.g. Node.js could fit here)
  • eliminate third-party stuff as much as possible (some kind of out-of-the-box solution like Django + Websockets and that's [it was really just a stupid example])
  • good documentation used with Django (it would be nice to have some real-world examples with my new technology and Django, since I have quite a few n00b for web servers and related stuff).
  • has a good perspective and future (I'm really looking to learn something that I will use a lot, and which I won't have to rebuild very often)

Thanks for your thoughts and any help on this (links to some good, recently updated readings are more than welcome :)

+3


source to share


1 answer


You should take a look at the django-socketio project, a Django application that provides the functionality you need to use websockets with Django over Socket.IO.



It uses the gevent library along with socket.io .

+1


source







All Articles