I think you should consider using a pool of limited connections, as in the database connection architecture.
Another solution that I would consider is a Pub / Sub database broker such as Redis. This allows you to use existing solutions, and also simplifies scaling.
As far as I understand, both having a single connection and using many connections have their own problems.
For example, one connection can send only one message at a time. A large enough message can block the connection ... are you moving big data?
Many connections can cause overhead, which can be very expensive, and also increase the likelihood of errors. Consider the following:
Creating new connections is very expensive, uses bandwidth, suffers from longer network latencies and requires local resources, and this is exactly what allows websites to avoid.
You will encounter scalability issues. For example, Heroku limits websocket connections to 600 per server, or at least they didnβt do it for long (and I think this is reasonable) ... How do you connect all the servers together to the same data store?
Remember that each OS has a restriction on open files and that web windows use the I / O architecture (each of them is an βopen fileβ, therefore web sites are a limited resource).
Regarding the speed / performance of traffic / data, this is a server architecture issue ... but I believe that you will see a slight increase in speed with a single connection (or a small connection pool). It is important to remember that there is no need to multitask when you need to send TCP / IP packets.
In addition, with a limited number of connections (even with one connection), you can use the connection function with the OS package, which will allow you to send several websocket frames over one TCP / IP packet (unless you constantly clean the TCP / IP connector). You actually spend more bandwidth on more connections β without even considering the bandwidth used to open every new connection.
Only my 5 cents, we will all think differently, I'm sure.
Good luck
source share