7

I've been developing a web server application with Django for the last year. The stack is Django + Apache + MySql. This stack was perfectly suited to our needs. Recently came the need of some real-time capabilities and the opportunity to change/rewrite a lot of stuff in the server application. To my surprise, Django is not the best option here.

I've been reading a lot (push, WebSockets, gunicorn... lots of stuff.. http://curella.org/blog/django-push-using-server-sent-events-and-websocket/) but I haven't managed to decide if I want to go with Django or if I should purpose a new stack of software which is more suitable for the job. Going with Django seems a little bit unnatural. Can any experienced developers point me in the right direction?

So, the basic question is: what are some alternatives to the current software stack I have for building a real time web application?

Thanks

PS: Not a native English speaker. :)

EDIT: The alternatives need to allow secure connections.

EDIT 2: The web applications we develop are games.

John R Perry
  • 3,916
  • 2
  • 38
  • 62
luistm
  • 1,027
  • 4
  • 18
  • 43
  • Be sure you are talking about real-time and not about hight performance. ["High-performance is indicative of the amount of processing that is performed in a given amount of time, while real-time is the ability to get done with the processing to yield a useful output in the available time."](http://en.wikipedia.org/wiki/Real-time_computing#Real-time_and_high-performance) – dani herrera Jan 30 '13 at 09:48
  • Not talking about high performance. – luistm Jan 30 '13 at 10:01
  • See [http://www.pixeldonor.com/2014/jan/10/django-gevent-and-socketio/](http://www.pixeldonor.com/2014/jan/10/django-gevent-and-socketio/) and [http://media.codysoyland.com/pdf/django-on-gevent.pdf](http://media.codysoyland.com/pdf/django-on-gevent.pdf) – Ajeeb.K.P Apr 30 '15 at 10:54

3 Answers3

2

You need to weigh your decisions against your goals.

You want a product

Then write your code in the language framework that you are most familiar with, only when you have a product and it has limitations consider switching tools.

You want to learn something new

Try out the new language, framework - but it may take a lot longer to produce a product and you may find that the new tool isn't any better than the old one.

Half and Half

Try starting two projects, and building the same thing in each project, just using the other tool. This will take even longer, but you should be able to see which tool you prefer / is best suited to your task very quickly.

Alternatives

I'm not quite sure what you mean by django is 'unnatural'. Django can do server / client communication - just use some AJAX to talk back to the django server, then call another pythonic library to process the request. Python alternatives to django include the wonderful flask and web.py, though neither will do client / server communication unless you program them too (like django). If you're not into python you might try ruby on rails. For the client side you will need to know something about JavaScript so go and learn up on that (coffescript and jQuery can ease JS pain, but do learn JavaScript first).

Of course you could bite the bullet and go with node.js as the server base, apparently it's pretty good (I've not tried it yet) - and written in JS.

EDIT: In light of your comments, take a closer look at

Noting also that this question is a potential duplicate.

Community
  • 1
  • 1
danodonovan
  • 19,636
  • 10
  • 70
  • 78
  • he wants to use somthing bigger than ajax like comet technologies and he just wonder whether django can handle it. His product is a web based game, therefore, i think he know what to do with the normal ajax stuffs – Thai Tran Jan 30 '13 at 09:56
  • Hi. Thanks for the answer. By 'unnatural' i mean, it can't send anything to the client unless the client makes a request. In my understanding, in a real time system, the server should be allowed to update the clients. If i have 5 players in a game (each one in is own browser) and one of them picks up the flag and wins, i want the others to know in that very moment. – luistm Jan 30 '13 at 10:00
2

Look into http://www.tornadoweb.org/ + http://www.mongodb.org/ + https://github.com/bitly/asyncmongo + http://socket.io/ I think it's a good idea to use that to create real-time application.

inlanger
  • 2,904
  • 4
  • 18
  • 30
  • I think i will continue to use django+apache, but i will add tornado for the real-time stuff, and use mongoDB or redis for cross communication between django and tornado. In front of these i will have nginx for redirecting every request to the proper webserver. – luistm Feb 04 '13 at 14:51
  • I would recommend using sock.js instead of socket.io – Edgar Navasardyan Dec 18 '16 at 15:38
1

For the real time web applications I suggest that you go with the websockets, they can be secure and response times are very fast as when connection is made there are no overheads in communication anymore. If you are proficient in python you can make server in python twisted and clients in python and/or javascript using autobahn. P.S. here is a really great tutorial for twisted.

Bula
  • 1,590
  • 1
  • 14
  • 33