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
Django still handles traditional HTTP, whilst Channels give you the choice to handle other connections in either a synchronous or asynchronous style. To get started understanding Channels, read our Introduction , which will walk through how things work.
Channels builds upon the native ASGI support available in Django since v3.0, and provides an implementation itself for Django v2.2. Django still handles traditional HTTP, whilst Channels give you the choice to handle other connections in either a synchronous or asynchronous style.
Enable persistent connections If the application needs to process a large number of requests, enable maintaining persistent connections to the database. Django closes the connection by default at the end of each request and persistent connections avoid overloading the database for each request.
If the application needs to process a large number of requests, enable maintaining persistent connections to the database. Django closes the connection by default at the end of each request and persistent connections avoid overloading the database for each request.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With