For terminal operators · check display rights for your product · Compare plans and subscribe
Size WebSocket bandwidth for a trading terminal
Estimate feed ingress and client egress separately. Work through a 54,000-viewer terminal and validate compression, fan-out and peak bandwidth.
By MadeOnSol · Updated
Integration choice
Size each delivery leg from its own measured traffic. The backend receives each distinct subscribed feed once per connection. Egress depends on the updates actually delivered to each viewer. A viewer count alone cannot determine the supplier bandwidth or the customer’s capacity.
Before you start
- Record concurrency, measured bytes and message rates for each leg.
- Use an isolated load-test environment with representative payloads and authorized synthetic clients.
Implementation steps
- Measure distinct inbound messages per second and wire bytes over a representative interval. Record snapshots and reconnect traffic separately from steady-state updates.
- Group viewers by watchlist and delivery rate. For each group multiply delivered frames per viewer per second by mean bytes per frame and concurrent viewers. Sum the groups.
- Measure with the compression settings actually negotiated on each leg. Record CPU, queued bytes per client and delivery delay as well as network throughput.
- Replay a busy period, then reconnect a cohort of clients. Measure short-window peaks. Choose capacity from the limiting direction and observed bursts, with explicit headroom.
How much bandwidth do 54,000 viewers use?
Illustrative assumptions: the backend receives 5,000 messages/s at 1,000 bytes each; each viewer receives two selected updates/s at 250 bytes each. The feed costs 40 Mbit/s inbound. Viewer delivery costs 216 Mbit/s outbound, or 27 MB/s. A second connection receiving the same whole feed adds another 40 Mbit/s inbound. These numbers model a workload and do not establish a supported capacity.
Where to measure compression
HTTP gzip on a snapshot says nothing about the WebSocket connection. Inspect the negotiated WebSocket extensions on both legs. If permessage-deflate is present, measure compressed traffic with realistic message sizes, mixes and connection settings. Count headers and TLS overhead at the network boundary or budget them separately. Avoid applying a compression ratio twice to already measured bytes.
How bursts and slow clients change the result
A mobile client draining slowly can build a long queue while aggregate bandwidth still looks healthy. Track queued bytes and the time from ingest to delivery. Coalesce replaceable state such as the latest displayed price. Preserve ordered trades and other history-dependent events through an appropriate recovery path. Measure snapshot bursts independently because a one-minute average can hide saturation.
Code examples
Reproduce the illustrative rates (standalone JavaScript)
function megabitsPerSecond(messagesPerSecond, bytesPerMessage) {
return messagesPerSecond * bytesPerMessage * 8 / 1_000_000;
}
const ingress = megabitsPerSecond(5_000, 1_000);
const egress = megabitsPerSecond(54_000 * 2, 250);
console.log({ ingress, egress }); // Mbit/s: 40 inbound, 216 outboundCommon mistakes and fixes
| Mistake | Recommended fix |
|---|---|
| Every browser is charged the entire supplier feed in the model. | Count the updates routed to each viewer cohort and measure backend ingress separately. |
| A 1 Gbit/s link is declared sufficient from average payload bytes. | Include short peaks, protocol overhead, CPU and client queues in the acceptance run. |
Verify your integration
Run the same watchlist with one client and then many clients on the same backend. Ingress should stay near its original rate while egress follows delivered updates. Repeat with distinct watchlists and a reconnect burst. Compare the model with directional byte counters over the same interval.
Production checklist
- Inputs include bytes, direction and sampling interval.
- Compressed and uncompressed runs use the same workload.
- The experiment records peak egress and delivery delay.
Frequently asked questions
Is 40 Mbit/s enough for 54,000 viewers?
In the example 40 Mbit/s describes the supplier leg only. Client egress is 216 Mbit/s before any overhead missing from the frame-size assumption.
What if two viewers open the same token?
Their backend watch can be shared. Each client connection still needs delivery, so both belong in the egress calculation.
