Skip to Content
LYNKORIADocs

Load testing

Repeatable API, messaging and media load tests, and the measured local results.

The 300-viewer livestream figure is a target, not a supported capacity. Only results from deployed infrastructure count toward capacity claims. Everything below was measured on one developer machine.

Tools

WorkloadToolLocation
HTTP API (tokens, calls, REST messaging)k6 (grafana/k6:1.3.0 container)loadtest/k6/api.js
Socket.IO fan-out latencyNode script with socket.io-clientapps/api/scripts/load-messaging.ts
Livestream mediaLiveKit's official lk load-test (livekit/livekit-cli:v2.13.2)loadtest/livekit/run.sh

Every script refuses *.lynkoria.com targets unless I_HAVE_PRODUCTION_AUTHORIZATION=yes is set. Use a dedicated load-test project and lynk_test_ key; raise its tokensPerMinute, maxConcurrentRooms and maxRoomSize limits first, or you will measure the limiter.

docker run --rm -i --add-host=host.docker.internal:host-gateway -e BASE_URL=http://host.docker.internal:3011 \
  -e SERVICE_KEY=lynk_test_… -e VUS=50 -e DURATION=60s grafana/k6:1.3.0 run - < loadtest/k6/api.js
BASE_URL=http://127.0.0.1:3011 SERVICE_KEY=lynk_test_… RECEIVERS=500 MESSAGES=60 RATE=5 \
  pnpm --filter @lynkoria/api exec tsx scripts/load-messaging.ts
BASE_URL=http://127.0.0.1:3011 SERVICE_KEY=lynk_test_… loadtest/livekit/run.sh "50 100 200 300" medium 45s

For staging, set LK_URL, LK_KEY, LK_SECRET and LK_NETWORK=host, run the load generators on separate machines from the media node, and record node CPU, memory and network with your monitoring stack (infra/monitoring).

Local results (2026-11-13)

Environment. AMD Ryzen 5 7500F (6 cores / 12 threads), 15 GiB RAM, WSL2 (kernel 6.18), Docker 29.9. One API process (built dist/, workers on, per-key limiter raised), PostgreSQL 18, Redis 8 and LiveKit v1.13.11 in local containers. Load generators ran on the same host, so they competed for CPU with the system under test. Raw output: loadtest/results/.

HTTP API (k6, 60 s per step; one iteration = token + create call + join token + end call + send message)

VUsRequests/sFailedAll requests p50 / p95 / p99 (ms)Token p95Join token p95REST send p95
204290.00%33 / 142 / 1992836199
5059540.0%*70 / 242 / 33378129354
1003800.37%*222 / 502 / 622221312622

* Every failure was connection refused from Docker Desktop's host.docker.internal forwarder (WSL → Windows → container), not an API response. The 50-VU step is therefore not a valid measurement. Throughput falling at 100 VUs while latency rises indicates the single API process (or the shared host) saturated; REST message send is the slowest path (per-conversation lock and sequence allocation in PostgreSQL).

Socket.IO fan-out (one sender, N receivers in one conversation)

ReceiversMessages × rateDeliveriesDelivery ratioDelivery p50 / p95 / p99 (ms)Send ack p95
50100 × 10/s5,000100%12.9 / 14.5 / 15.915.0
200100 × 10/s20,000100%15.6 / 18.4 / 19.719.9
50060 × 5/s30,000100%20.2 / 25.6 / 17328.5
99930 × 2/s29,970100%29.0 / 37.8 / 42.543.7

Conversations are capped at 1,000 members. These are local loopback numbers with one API process.

Socket.IO fan-out across two API instances (2026-11-14)

Apple M1 Pro (8 cores), 16 GiB, macOS with Docker Desktop. Two API processes (apps/api/scripts/e2e-server.ts, same database, Redis and secrets) with the Redis Streams adapter (ADR 021); the sender is on instance A and receivers alternate between A and B, so half of all deliveries cross instances through Redis. The one-instance rows put every receiver on A for comparison. Generator on the same host. Raw output: loadtest/results/socket-fanout-multi-instance-local.txt.

ReceiversMessages × rateInstancesDelivery ratioDelivery p50 / p95 / p99 (ms)Send ack p95
200100 × 10/s1100%39.4 / 55.5 / 63.750.4
200100 × 10/s2100%35.9 / 52.1 / 55.244.9
50060 × 5/s1100%48.5 / 65.3 / 76.051.2
50060 × 5/s2100%45.9 / 63.1 / 71.848.2
99930 × 2/s1100%52.2 / 70.3 / 75.448.9
99930 × 2/s2100%52.6 / 73.8 / 90.851.3

Crossing instances added no measurable median latency at these rates; p99 rose at 999 receivers. Every delivery arrived. This machine differs from the one used for the single-instance table above, so compare rows within this table only.

Failure drills

node scripts/failure-drills.mjs stops Redis, PostgreSQL and LiveKit one at a time (abruptly, docker stop -t 0) under a running API, then restarts them. Raw output: loadtest/results/failure-drills-local.txt.

Dependency down/health/readyRequest during outageRecovery after the container is healthy
Redis503Messaging token: 503 (rate limits fail closed)21 ms
PostgreSQL503Messaging token: 503 with Retry-After52 ms
LiveKit200 (unchanged)Create call: 503; messaging token: 20018 ms

The first PostgreSQL drill crashed the API process: an idle pooled connection's termination (57P01) was an unhandled error event. The pool now handles it, a regression test terminates a pooled backend, and database outages return a retryable 503 instead of 500.

Livestream viewers (lk load-test, 1 simulcast video publisher, 45 s per step)

ViewersResolutionSubscribedAggregate bitrate (avg/viewer)Packet lossLiveKit CPU†LiveKit memory
50medium50/5016.8 Mbps (336 kbps)0%16%439 MiB
100medium100/10032.4 Mbps (324 kbps)0%31%333 MiB
200medium200/20060.5 Mbps (303 kbps)0%59%427 MiB
300medium300/30085.9 Mbps (286 kbps)0%80%598 MiB
300high300/300217.7 Mbps (726 kbps)3.22%175%621 MiB

† docker stats percentage of one core, sampled mid-run. Simulated subscribers receive but do not decode media, and all traffic stayed on loopback, so real client CPU, Wi-Fi/cellular loss, TURN relay and internet egress are not represented. The 3.2% loss at high resolution happened with the load generator sharing the host; whether it is server- or generator-side is unknown.

Bandwidth estimate. At ~0.3 Mbps per medium-quality viewer, 300 viewers need ~90 Mbps of egress, about 40 GB per hour of streaming (≈0.14 GB per viewer-hour); at high quality ~220 Mbps (≈100 GB per hour). Price and size the media node's transfer accordingly.

Not yet measured

Staging or production environments; multiple concurrent livestreams; viewer join/leave churn; network interruption; recording/Egress under load; HLS delivery; push throughput against real providers; scanner throughput; storage throughput; reconnection time; jitter and end-to-end media latency. A 300-viewer claim requires repeating the viewer test on the deployed media node with generators on separate machines.

On this page