WebSocket Capacity Calculator

🔒 Processed 100% in your browser — nothing is uploaded

About this tool

A WebSocket server is not a request handler — it is a landlord. Connections check in and stay for minutes, hours or weeks, and the server keeps every room warm the whole time. A normal HTTP request arrives, gets processed and leaves, so CPU or database headroom is the limit. A long-lived connection never leaves: it holds a read buffer, a write buffer, session state and a TLS context — tens of KB before any business logic runs — while costing almost no CPU. That is why push services, chat backends, collaborative whiteboards and IoT gateways hit a memory and fd wall, not a compute wall: 100,000 connections at 20 KB each is 2 GB of RAM before a single message flows.

This calculator answers the question in its title from the angles that decide it. The Connections tab takes memory per connection, usable RAM and the process fd limit, sets one box's ceiling at the smaller of the two, and converts a target count into a number of boxes. The Broadcast tab sizes fan-out: one message to N clients over TCP means N copies on the wire; it turns message size and rate into MB/s and Gbps against your NIC, and shows where IP multicast would and would not help.

The Heartbeat tab counts what it costs to know your connections are alive: ping and pong packets per second, the bandwidth they use, and — the part people forget — how long a silently dead connection keeps occupying memory before the timeout reclaims it. The Memory tab builds the per-connection budget from its parts (read buffer, write buffer, session state, TLS overhead, safety margin) and reverse-solves how many connections fit a given machine. The Summary tab combines a fresh copy of these inputs into one recommendation — connections per box, box count, bandwidth, heartbeat share — in plain words.

The same arithmetic covers a surprising range of decisions, because they differ only in the constants: a chat connection carries more session state than a push socket, an IoT gateway may hold half a million devices sending one tiny reading a minute, a whiteboard broadcasts continuously and hits the bandwidth wall long before the memory wall.

Two warnings before you trust the output. First, the memory figure you type is the whole calculation — measure it on your own stack (RSS before and after adding 10,000 connections in a load test) rather than copying a blog post's constant. Second, an nginx-style proxy consumes fds and buffers for both sides of every connection and can exhaust itself first, and WSL or laptop numbers do not transfer to production Linux; the FAQ covers both. Then load-test the real thing.

How to use WebSocket Capacity Calculator

  1. Connections: enter memory per connection (KB), usable memory per box (GB), the fd limit per process and your target connection count; read the per-box ceiling, which limit binds, and how many boxes the target needs.
  2. Broadcast: enter connected clients, message size and broadcast rate; read egress in KB/s, MB/s and Gbps against the NIC limit, with a unicast fan-out vs IP multicast comparison.
  3. Heartbeat: enter connections, ping interval, timeout, memory per connection and the silent-disconnect rate; read packets/s, KB/s of keep-alive, how long dead connections hold memory, and the interval trade-off table.
  4. Memory & Summary: build the per-connection budget from read/write buffers, session state, TLS and a safety margin, then combine everything into a recommended per-box count, fleet size and a plain-language conclusion.

Frequently asked questions

Why is memory, not CPU, the bottleneck for WebSocket servers?

An idle connection costs a few microseconds of CPU per second but holds tens of KB of memory — read buffer, write buffer, session object, TLS state — for as long as it stays open. A server that could process 50,000 requests per second can run out of RAM holding 20,000 idle connections. Capacity planning for long connections is memory arithmetic, not load arithmetic.

What do C10K and C1M actually constrain?

The C10K problem — 10,000 simultaneous connections — was about OS limits: one thread or process per connection exhausted memory and the scheduler long before 10,000. epoll/kqueue and reactor designs solved the CPU side, which is why C10K is table stakes today. C1M is the modern version, and the constraints moved to per-connection memory, the fd limit and kernel socket buffer tuning — none of which a faster framework fixes.

How do I raise the fd limit (ulimit)?

Check the current soft limit with ulimit -n, then raise it: soft and hard nofile lines in /etc/security/limits.conf, or LimitNOFILE= in the systemd unit file. The hard ceiling is the fs.file-max and fs.nr_open sysctls. Verify on the running process with cat /proc/<pid>/limits — and remember every hop in front of your server (nginx, load balancer, container runtime) has its own limit that can run out first.

How do I choose a heartbeat interval?

Below the smallest idle timeout on the connection's path. NAT gateways, firewalls and mobile OSes silently drop idle mappings after roughly 30–300 seconds without telling either side, so a connection can be dead while both endpoints still believe in it. 30 seconds is a common default; a 10-second interval detects deaths 3x faster at 3x the packets. The Heartbeat tab puts both numbers — packet rate and dead-connection memory — side by side.

How do I estimate broadcast bandwidth?

Connections x message size x messages per second — over TCP every client receives its own copy of every message. Example: 10,000 clients receiving one 1 KB message per second is about 10 MB/s, or 0.08 Gbps. Audience and rate multiply linearly from there; the Broadcast tab does the conversion and shows what percentage of your NIC that consumes.

How much memory does TLS add per connection?

Count on roughly 10–40 KB per connection for session state, cipher context and handshake buffers of an OpenSSL/BoringSSL connection, depending on protocol version and ciphers; TLS 1.3 with session resumption sits at the low end. The Memory tab has a dedicated input for it — set it to 0 if TLS is terminated upstream at a load balancer, then budget that box's memory instead.

What does an nginx proxy do to WebSocket capacity?

In HTTP Upgrade mode a proxy holds one connection to the client and one to your backend: two fds and two sets of buffers per user, so its memory per connection joins your budget and its fd limit becomes a fleet ceiling. Size the proxy tier with the same arithmetic as the app tier, raise its limits too, or remove the hop with an L4 balancer (HAProxy TCP mode, IPVS, a cloud NLB) that forwards bytes without parsing them.

Do capacity numbers measured in WSL or on a laptop transfer to production?

No. WSL2 runs a real Linux kernel but inside a VM with its own memory allocation, NAT networking and default fd limits; macOS adds its own socket defaults. Fine for developing the code — but measure per-connection memory and fd behavior on the production kernel, container limits included: a Docker memory cap or a low LimitNOFILE changes the answer more than any code change.

Is my data uploaded anywhere?

No. Every calculation runs locally in your browser with JavaScript. Nothing you type — memory figures, connection counts, NIC sizes — is transmitted, logged or stored.