I have a socket.io socket room, whose traffic is becoming more and more as we work on the same machine. We ran tests using the ws library for sockets, and they perform much better, which uses our equipment better. It will be worth it to rewrite our application.
The socket.io application allows users to create private chats that are implemented using namespaces. For example,
localhost:8080/room/1
localhost:8080/room/2
localhost:8080/room/3
When everything happens in one instance, it is quite simple, but now we want to expand this capacity to several nodes.
We run this instance in the Amazon cloud. Previously, it looked like scaling websockets was a problem with ELB. We noticed that Amazon now also supports application load balancing, which supports websockets. That sounds great, but after reading the documentation, I have to admit that I really don't know what that means. If I use socket.io with thousands of namespaces, I just put instances behind this ALB and everything will work? My main questions are:
If x is the number of users joining the namespace, will ALB automatically redirect my messages to the right users as well? So, let's say I have 5 instances of vanilla socket.io working for ALB. User 1 creates a namespace. After a few hours, the transition will pass and user 99999 will come and want to join this namespace, should there be any additional code written for this, or should alb redirect everything where it should go? The same goes for sending and receiving messages?
source
share