0

I'm developing a Node.js back-end which communicates with some desktop clients via websockets, and the communication from the server side is initiated from a web front-end. Everything works ok since I am storing the SockJS Connection instances in an array. But if I would like to scale out the service, I guess no such thing would work, I need to share the connections or something like that.

Is there any way to do this, or change my architecture in any way to support the scaling one day?

Aleksandar Stojadinovic
  • 4,851
  • 1
  • 34
  • 56

1 Answers1

1

You could scale horizontally by using a load balancer in front of multiple SockJS servers. If you need to share data across multiple SockJS servers, you could use one or more Redis instances (this is what the socket-redis module does).

mscdex
  • 104,356
  • 15
  • 192
  • 153
  • So, if I understood correctly, with socker-redis it is not important to which server the websocket is connected too? Communication is "delegated" through a redis interface? Does it matter that I am using a desktop client for the communication, not a web interface? – Aleksandar Stojadinovic May 20 '14 at 07:52
  • You're correct about socket-redis. I'm not too familiar with SockJS, but assuming it does not have a custom protocol underneath like Socket.IO/Engine.IO, then any normal websocket connection should just work. – mscdex May 20 '14 at 13:23