Why Do We Need Socket.IO Scaling?

So far, our application has used a single Node.js server instance.

All connected sockets are maintained within that server process.

Consider what happens when you deploy two Node.js instances behind a load balancer.

  • User A connects to Server 1.
  • User B connects to Server 2.
  • User A sends a message.
  • Server 1 broadcasts the message using its local Socket.IO instance.

Without a shared adapter, Server 2 does not automatically receive the broadcast.

This happens because the default Socket.IO adapter stores room and socket communication state locally within each server process.

To solve cross-instance communication, we need an adapter that distributes broadcasts between server instances.

Problem Without Shared Adapter
Key Takeaways
  • The default adapter is local to a server instance.

  • Multiple server instances do not automatically share broadcasts.

  • A distributed adapter enables cross-instance event communication.