Max Number of WebSocket Connections that a Single Nats Server can Sustain Reliably #2770
-
( Assume below that the nats-server in question has 128GB of RAM and "beast-mode" ARM CPUs )
PS: I'm sorry if this has been answered elsewhere but I just couldn't spot anything anywhere in the official docs |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is a great question. In general, I usually start with what resource will be most constrained. This can be memory, network, or CPU (depending on latency and throughput targets). For connection's memory footprint, it's fairly simple to run a quick test to measure for yourself the weight of an idle connection in your setup. Last we looked you should see ~20-30k or so per on avg. Note to pay attention to how many connections would need to fail over in case of a server loss or upgrade, and whether those connections are TLS based (esp RSA). That could cause thundering herd and CPU issues. Most clients have jitter baked in, and ECC keys help alot, but something to keep in mind when scaling up the connections per host. I have ran experiments with ~1M mostly idle connections on a single server. For CPU it usually is around a throughput or latency target, meaning the network is not the constrained resource. For the situation above, since you have a good sense of traffic patterns, we can more accurately look at the network resources. If I am doing my math correct, each client does ~1mb/hr or ~8mbit/hr, which translates to 2222.22 bps. Good number ;) So again, if math correct, that means on a 10Gb network interface, you can do ~4M connections. So for above I would say your main concerns will be memory (you have plenty in the above scenario) and client reconnects on server disruption as what to plan around. More the later then the former in my opinion. Hope that helps. |
Beta Was this translation helpful? Give feedback.
This is a great question.
In general, I usually start with what resource will be most constrained. This can be memory, network, or CPU (depending on latency and throughput targets).
For connection's memory footprint, it's fairly simple to run a quick test to measure for yourself the weight of an idle connection in your setup. Last we looked you should see ~20-30k or so per on avg.
Note to pay attention to how many connections would need to fail over in case of a server loss or upgrade, and whether those connections are TLS based (esp RSA). That could cause thundering herd and CPU issues. Most clients have jitter baked in, and ECC keys help alot, but something to keep in mind when scaling …