[Solved]-Is django-channels suitable for real time game?

12👍

To begin with, channels is nothing but an asynchronous task queue. It’s very similar to celery, the major difference being in performance & reliability.
Channels is faster than celery but celery is more reliable. To add more context to it, channels executes a task only once (irrespective of whether it fails or succeeds). On the other hand, celery executes the tasks until the tasks fail a certain number of time or it succeeds.

Now, coming to your questions & taking this example.

Suppose you were to build clash of clans using channels &
web-sockets.

1) Yes, channels is suitable for real time game as long as you write custom logic for the situations where the task in the async queue fails.

The web-sockets will send & receive messages via channels. So, in case where one of the players’ request to deploy a troop on the battlefield is not successfully sent to the server, you need to write custom logic to handle this situation (like trying a request at least 3 times before dumping it out of the task queue).

2) Not really. They are pretty much the same. Ultimately you’ll have to use web-sockets & a queue where you can fire/receive messages simultaneously.

3) Yes, you’ll have to implement a web-socket in your application (android, iOS, desktop) which’ll send/receive messages from the backend via channels.

Leave a comment