I maintain a Django Channels v1 app with six Consumers multiplexed over one WebSocket connection. I'm upgrading to Django Channels v2, where connection (de)multiplexing is no longer supported; see GitHub Issue #825 - (Re)Implement Multiplexing. If I want to multiplex, I can use channels-demultiplexer, channelsmultiplexer, or write my own. I'm leaning towards re-implementing multiplexing because I think it would entail changing less of our existing code.
Before doing that, I'm doing some due diligence to find out whether multiplexing is even an important optimization.
Given a Redis-backed Django 2 + Channels 2 app in a load balanced environment behind Nginx with Daphne (currently planning mostly SyncConsumers) and Gunicorn, I think that increasing the number websocket connections by 3x-5x would only negligibly increase Redis RAM, app server RAM, and Daphne CPU, and also negligibly increase browser RAM and CPU, but that's just an educated guess.
- How should I think about the cost of each additional WebSocket connection a.) in Django Channels v2 and b.) in the browser?
- I have not seen any web apps that were designed to use many WebSocket connections on a single page. Have you? If so, is it performant? How many connections did it utilize?
- What would you do?
Stack Overflow posts that address adjacent but different questions: