This is a super general question but if you can, play along and entertain my curiosity.

For a barebones simple messaging app to work that maintains at the most 1000 connections at once, each user expects real time updates to when a message is incoming.

I can use redis pub/sub to handle the multicasting needed so that users are not all dangling on websockets together but for a user to even know in real time that a message has been broadcasted for them and that they're client needs updated with the message, would a websocket for each client still be needed ?

And if so, each user cant connect to one socket that relays all information so each user ideally would have a connection over lets say /engine/listen/<user-id>.

Does this sound like an approach thats even near right and if so, how many of these websocket connections can be maintained on a given server ?
Do i need to have as many instances running in each most readily available zone for each limit met in websocket connections ?

  • 1
    If you don't plan on storing the messages in a datastore, each client (the user) should be connected via WS. This then means that users who are offline can't see the messages that were sent during that time. Same goes with redis pub-sub. Only the curently active subscribers get the messages

    Regarding the number of connections a server can support, it is really a matter of performance/benchmark testing simulating the expected max concurrent connections

    Also, have you considered XMPP and the like?
  • 0
    @asgs luckily this idea im playing with is based on clients speaking to each other only when online within close proximity and messages wont be persistant. My understanding of websockets has been that they demand a port for each socket and thats where i get confused as there are only so many available ports to consume. I have looked into that standard and a few others though. Even though i have a good chunk of the POC built out other then the messaging portion, Im still toying around with how capable it is.
  • 0
    @dUcKtYpEd WS is nothing different from other communication protocols. Every incoming connection needs a local port on the server sending them the messages

    If resource limits are the problem (and they will be), have a load balancer and an auto scaling policy based on the right system metrics
  • 1
    @asgs makes sense. I guess my understanding is off about them. Sense one client maintaining a connection uses one port, my understanding is that if there are 1000 ports and 1000 users connected to a chatroom, I would then need another instance per MAX_PORTS being used.
Add Comment