Socket.io in multi-server load-balanced environment

Hi all,

We’re soon moving to a load-balanced NodeJS environment and thinking about how our socket/emit messages will reach all servers. We’ve moved to a single Redis server (DO) to manage all sessions (instead of one per app server). Does Wappler’s socket.io offer some way of broadcasting to all servers or is this something we’d need to wrap up in some other way ?

Thanks
John

I believe using a single Redis server is enough, based on this answer:

1 Like

Thanks Apple.

At the moment we have a single Redis server to manage session state. It’s not configured in any way for our sockets. Happy using the one server but how to ensure it’s managing th sockets is the question - does Wappler offer way to configure it this way?

-John

Seems that sockets will be aware of redis and perform accordingly.

Thanks Apple

Yeah, Wapplers default behavior works fine. I use a DO redis cluster for sockets as well and 32 containers for the application. It works without any issues.

2 Likes

Perfect thanks.

32 seems very scalable. We run with one container per virtual server and load balance behind DO’s LB.

What kind of RAM are you allocating to each…?

@scalaris The 32 containers are just one middleware of the application. The amount of ram always depends on what runs in the containers. These 32 containers each have two GB of ram assigned and a single core because they handle chromium-related tasks and never open more than two browser instances with a single tab each.

I’m considering moving away from DOs managed Redis databases and self-hosting them because their managed option has limitations. The same goes for Postgres, where the managed option is limited due to licensing. https://www.dragonflydb.io/ is interesting as well, and I’m currently testing it because I will need to scale the application further soon.

2 Likes

Thanks. Great insights. Keen to hear how dragonfly db works out

Quick summary of my dragonflydb tests:

  • 100% compatible with Wappler
  • Veeeeeery fast
  • 100% compatible with ioredis and bull queues
  • I’m deploying it to the first production middleware

Maybe a good topic for a YouTube video.

5 Likes

Very interested in that proposed YouTube video

1 Like