Content CPU · runtime

Threads and Platformatic Watt

One event loop caps a content pod at ~1.2 of 2 cores. Two worker threads, measured with our own launcher and with Watt 3.77, on throughput, CPU, balance and a stuck-worker test.

Measured by Claude (agent) in the HOI-4097 UAT lab

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

WhoWhat they runWhat they measuredSource
X (logged-out x.com, published 2026-11-04)Platformatic Watt on Node.js v26, several worker threads in one process; stuck workers replacedBefore 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 workersX 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 nginxAdventures 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_threads inside one process; the entrypoint listens with reuseTcpPorts (default true), so the kernel spreads connections across workers (config).
Health and replacement
A worker is checked every interval (default 30 s); after maxUnhealthyChecks (default 10) consecutive bad checks (ELU over maxELU 0.99, heap over maxHeapUsed 0.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/node runs an unmodified self-listening app; Watt replaces the port it listens on. No code change to content.
Probes and metrics
Optional Prometheus server with /ready and /status endpoints (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).

RouteEncodingreq/s 1 threadreq/s ours ×2vs 1req/s Watt ×2vs 1CPU ms 1tCPU ms oursCPU ms Wattp99 1tp99 oursp99 WattWatt busiest/other workerErrors
Watch-listuncompressed7371,150+56%1,064+44%1.661.741.8698891001.00×0
Single titleuncompressed583903+55%775+33%2.082.182.54105961201.01×0
Watch-history displayuncompressed488771+58%727+49%2.442.602.711211111281.13×0
contentDatauncompressed1,2462,059+65%1,892+52%0.900.970.984953541.01×0
Page routescompressed2227+23%24+11%73.1572.0878.331,3961,2911,1661.43×0
Entitlementcompressed219316+44%316+44%5.365.715.503012822821.05×0

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.

Runtime0–10 s10–20 s20–30 s30–40 s50–60 s80–90 s90–100 sServed over 120 s
1 thread (today)0/400/400/400/400/402/4040/4025.5%
Our launcher, 2 threads21/4026/4017/4021/4020/4021/3940/4066.2%
Watt 3.77, 2 workers0/400/400/4010/4024/4020/3940/4047.8%

Integration notes found in the lab

Recommendation

OptionGain per podCost / riskFit
Stay on 1 thread—Pod capped at ~1.2 coresToday
Our launcher, 2 threads+23% to +65% req/s~60 lines we own; no worker replacement; kernel hash balanceBest raw throughput
Watt, 2 workers+11% to +52% req/sNew dependency; 5–20% more CPU/req; OTel metrics conflict to fix; 1.43× imbalance on pagesBest 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.