14

I am using Django channels for chat application. This application might scale to 100k concurrent users in some amount of time. I am wondering how many concurrent connections can Django Channels handle. Basically, what I am comparing it with is XMPP server, that whether XMPP is a better choice for scalability or I should continue with Django channels?

Also, I am using a redis layer as the channel layer. I was wondering if redis layer can be a bottle neck at some point of time?

Thanks

hardik24
  • 1,008
  • 1
  • 11
  • 34
  • Basically, your question is more related to the actual ASGI server that will be used to serve your django-channels application. Django channels has it's own official server - [Daphne](https://github.com/django/daphne) which uses asyncio under the hood and is quite scalable by itself. You can also use alternative servers for your channels app such as [uvicorn](https://www.uvicorn.org/) – Olzhas Arystanov May 13 '20 at 18:23

1 Answers1

7

ASGI (Asynchronous Server Gateway Interface) is intended to provide a standard interface between async-capable Python web servers, frameworks, and applications.

In Django Channels, even though Django itself in a synchronous mode it can handle connections and sockets asynchronously.

Websockets go into a server called Daphne (Daphne is a HTTP, HTTP2 and WebSocket protocol server for ASGI and ASGI-HTTP, developed to power Django Channels) can handle hundreds or potentially thousands of simultaneous connections open at once.

Any event on a websocket (connect, message received) is sent onto the channel layer, which is a type of first-in-first-out queue

Django worker processes synchronously take a message from the queue, process it, and then loop back to take another.

So, the number of open connections affects how many Daphne instances you run. And throughput of events affects the number of workers you run.

psorab
  • 135
  • 1
  • 16