What this page shows
One Node event loop caps a 2-CPU content pod at ~1.2 cores. Running two worker threads in the same pod lifts requests per pod by +23% to +65% (our launcher) or +11% to +52% (Platformatic Watt) at the same CPU limit, with identical responses. Watt adds automatic replacement of stuck workers and a health server, at 5–20% more CPU per request than a bare launcher, and its shared port left one worker doing 1.43× the other's work on page routes.
Why threads at all
On one thread the content pod plateaus at about 1.2 of its 2 cores with event-loop utilisation ~0.8 (see the capacity sweep). Extra connections only add latency. That is the same limit X describes for its logged-out web server.
What X and Booking.com report
| Who | What they run | What they measured | Source |
|---|---|---|---|
| X (logged-out x.com, published 2026-11-04) | Platformatic Watt on Node.js v26, several worker threads in one process; stuck workers replaced | Before the change, per-worker event loop busy 67% (median) / 84% (p95); longest stall 1.9 s / 3.7 s; a 1 s upstream timeout fired on 1–9% of renders although the upstream answered in ~25 ms. Fix: spread the same traffic across more workers | X engineering blog |
| Booking.com (main Node rendering service) | pm2 cluster → Watt worker threads with SO_REUSEPORT | −38% compute cost, −30% pods, −20% memory per pod, up to −10% p75/p99/p99.9; 40–50% more requests within SLO. SO_REUSEPORT left some threads up to 40% busier; fixed with per-worker ports (portAssignment: perWorkerIncrement) behind nginx | Adventures in Nodeland |
X's timer detail matches our own finding: a busy event loop makes upstream timeouts fire late or spuriously, so CPU saturation shows up as timeouts and 504s, not only as slow requests.
How Watt works (from its docs)
- Model
- Each application runs as
worker_threadsinside one process; the entrypoint listens withreuseTcpPorts(default true), so the kernel spreads connections across workers (config). - Health and replacement
- A worker is checked every
interval(default 30 s); aftermaxUnhealthyChecks(default 10) consecutive bad checks (ELU overmaxELU0.99, heap overmaxHeapUsed0.99, or no answer) it is replaced: a fresh worker starts first, then the old one is retired (lifecycle). With defaults that is about 5 minutes; we used 5 s × 6 = 30 s. - Crashes
restartOnError: immediate restart in production; up to 5 bootstrap attempts.- Wrapping our app
@platformatic/noderuns an unmodified self-listening app; Watt replaces the port it listens on. No code change to content.- Probes and metrics
- Optional Prometheus server with
/readyand/statusendpoints (off unless configured).
Lab setup
// watt.json (runtime)
{
"entrypoint": "content",
"server": { "hostname": "0.0.0.0", "port": 3002 },
"reuseTcpPorts": true,
"workers": { "static": 2 },
"restartOnError": true,
"health": { "enabled": true, "interval": 5000, "gracePeriod": 60000,
"maxUnhealthyChecks": 6, "maxELU": 0.99, "maxHeapUsed": 0.95 },
"applications": [{ "id": "content", "path": "./web/content", "workers": 2 }]
}
// web/content/watt.json
{ "node": { "main": "/work/main.js" } }wattpm / @platformatic/node / @platformatic/runtime 3.77.0 (latest), Node 26.13, the same final content bundle (all changes through #19), same m8g.xlarge lab node and 2-CPU pod limit as every other run. Our launcher (mt-launch.js) starts 2 worker_threads that each run the unmodified bundle and listen on :3002 with reusePort.
Output check
Watt vs plain node, same requests at the same moment: 0 differences on 400 requests (100 each: watch-list, single title, contentData, watch-history display).
Throughput, CPU and balance
32 connections (8 for page routes), 20 s per run, 3 interleaved rounds per runtime, medians. CPU ms is pod CPU per successful request. Busiest/other worker is the CPU-time ratio of Watt's two worker threads during the run (1.00× = even).
| Route | Encoding | req/s 1 thread | req/s ours ×2 | vs 1 | req/s Watt ×2 | vs 1 | CPU ms 1t | CPU ms ours | CPU ms Watt | p99 1t | p99 ours | p99 Watt | Watt busiest/other worker | Errors |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Watch-list | uncompressed | 737 | 1,150 | +56% | 1,064 | +44% | 1.66 | 1.74 | 1.86 | 98 | 89 | 100 | 1.00× | 0 |
| Single title | uncompressed | 583 | 903 | +55% | 775 | +33% | 2.08 | 2.18 | 2.54 | 105 | 96 | 120 | 1.01× | 0 |
| Watch-history display | uncompressed | 488 | 771 | +58% | 727 | +49% | 2.44 | 2.60 | 2.71 | 121 | 111 | 128 | 1.13× | 0 |
| contentData | uncompressed | 1,246 | 2,059 | +65% | 1,892 | +52% | 0.90 | 0.97 | 0.98 | 49 | 53 | 54 | 1.01× | 0 |
| Page routes | compressed | 22 | 27 | +23% | 24 | +11% | 73.15 | 72.08 | 78.33 | 1,396 | 1,291 | 1,166 | 1.43× | 0 |
| Entitlement | compressed | 219 | 316 | +44% | 316 | +44% | 5.36 | 5.71 | 5.50 | 301 | 282 | 282 | 1.05× | 0 |
- Both thread options beat one thread on every route. The gain is largest on CPU-bound uncompressed routes and smallest on pages, where compression already used the second core.
- Watt costs 5–20% more CPU per request than our launcher (single title 2.18 → 2.54 ms, pages 72 → 78 ms): its main thread, interceptor mesh and own telemetry share the same 2 cores.
- Watt's shared-port balance is even on short requests (1.00–1.05×) but 1.43× on page routes (few long requests), the same kernel-hash effect Booking.com fixed with per-worker ports.
One stuck worker
One request busy-loops a thread for 90 s (a stuck render). A new connection to /health is opened every 250 ms (1 s timeout) for 120 s. Cells are successful probes out of ~40 per 10 s of real time.
| Runtime | 0–10 s | 10–20 s | 20–30 s | 30–40 s | 50–60 s | 80–90 s | 90–100 s | Served over 120 s |
|---|---|---|---|---|---|---|---|---|
| 1 thread (today) | 0/40 | 0/40 | 0/40 | 0/40 | 0/40 | 2/40 | 40/40 | 25.5% |
| Our launcher, 2 threads | 21/40 | 26/40 | 17/40 | 21/40 | 20/40 | 21/39 | 40/40 | 66.2% |
| Watt 3.77, 2 workers | 0/40 | 0/40 | 0/40 | 10/40 | 24/40 | 20/39 | 40/40 | 47.8% |
- One thread: nothing is served while the loop is stuck.
- Our launcher: the healthy thread keeps serving, but the kernel still hands about half of new connections to the stuck thread, for the whole stall.
- Watt: it detected the stuck worker and logged
is unhealthy. Replacing itafter ~30 s (6 checks × 5 s), and a replacement worker took traffic. But the stuck worker cannot be closed while its JS is spinning, so it keeps receiving its share of connections until the stall ends; in the first 30 s no probe succeeded at all. Replacement bounds how long a worker stays bad when it eventually yields (memory leaks, slow drift); it does not rescue a worker that never yields.
Integration notes found in the lab
- OpenTelemetry metrics export fails under Watt:
PeriodicExportingMetricReader: metrics export failed (Parse Error: Expected HTTP/…). The app's OTLP/HTTP exporter receives an HTTP/2 frame; 0 such errors on plain node. Traces/logs and responses unaffected. Needs fixing before any rollout (Watt ships its own telemetry; one of the two must own export). - Startup: under Watt the app still logs its own Nest startup per worker; boot to healthy took ~2 s in the lab.
- Health defaults are slow: 30 s × 10 checks ≈ 5 minutes before replacement; we used 5 s × 6.
- Kubernetes: probes should target Watt's health server (
/ready,/status) rather than an app route, so a single stuck worker does not fail the whole pod.
Recommendation
| Option | Gain per pod | Cost / risk | Fit |
|---|---|---|---|
| Stay on 1 thread | — | Pod capped at ~1.2 cores | Today |
| Our launcher, 2 threads | +23% to +65% req/s | ~60 lines we own; no worker replacement; kernel hash balance | Best raw throughput |
| Watt, 2 workers | +11% to +52% req/s | New dependency; 5–20% more CPU/req; OTel metrics conflict to fix; 1.43× imbalance on pages | Best operability: replacement, health server, per-worker ports, used at X and Booking.com |
Either way the next step is the same: a UAT soak with 2 threads per pod and per-thread Mongo/Valkey pool sizing. If stuck-worker replacement and probes matter more than the last 10–15% of throughput, take Watt and fix the OTel export first.