How to achieve horizontal scaling with multiple Nats Server? #3198
-
Hello guys i'm thinking to move my production from socket.io to Nats.io and the first question come to my mind is how i can scale it with load balancing and horizontal scaling where each nats server communicate to master or main server please explain it with details some sample code to achieve this. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
If you utilize the client and NGS, that is all included and automatic. We resolve connect.ngs.global to the nearest server with the same cloud affinity. If you want to do this yourself, we do not necessarily recommend LBs, but folks do try to use them. You could simply have a DNS c-name record with all the A records for the nats-servers in the cluster. NGS simplest imo.. |
Beta Was this translation helpful? Give feedback.
-
If they are co-located geo wise, run a 3 node cluster, put all three servers A records in a DNS cname which is what your web clients will use to connect. |
Beta Was this translation helpful? Give feedback.
-
Might recommend 8 core.. But you can easily test to make sure. |
Beta Was this translation helpful? Give feedback.
-
NATS is usually considered extremely performant. If you have the code to test your app with the NATS client, you could point them at our demo server. wss://demo.nats.io:8443 |
Beta Was this translation helpful? Give feedback.
If they are co-located geo wise, run a 3 node cluster, put all three servers A records in a DNS cname which is what your web clients will use to connect.