Forty services and the start gate
Forty copies of one small Hono server, split by templates into api, web, worker and job services. Each works for a random 1 to 6 seconds before it is ready, so a start fills the machine-wide start gate and the resource monitor (M in the TUI) has something to draw.
Requirements
Section titled “Requirements”- devlanes, with
devlanes setuprun once - Node 22.18 or later, which runs
scripts/generate.tswithout a build step
Run it
Section titled “Run it”cd showcase-many-servicesdevlanes startOpen https://example-many-services.localhost. The index page links to each of the 40 services of lane 0 (index, api-01 and web-01 have hostnames, the other 37 link to http://127.0.0.1:<port>) with its kind, ready time, CPU bursts and CPU time, and it reloads every 2 seconds so you can watch the count of services that answer go up during a start.
During a start
Section titled “During a start”- The first start of a lane runs the
installtask,npm install && npm run build, which compilessrc/todist/. - Every service runs
node dist/index.jswithKIND,BOOT_MS,BURST_MSandBURST_EVERY_MSfrom its template. It works forBOOT_MSbefore it listens onPORT. - Each service holds a slot in the start gate until its ready check passes:
ready.httpon/healthzforapiandweb, the log lineready after(ready.log) forworkerandjob.
The start gate decides how many services may be starting at the same time, across every lane and project on the machine. The rest wait as queued. With the default startup.mode: adaptive, the window starts at startup.max, which defaults to the number of CPU cores. It halves after 3 seconds above 90% CPU or under memory pressure, and grows by one slot every 2 seconds while system CPU stays below startup.target_cpu (75%).
On a 20-core machine, 20 services started and the rest queued. devlanes status a second into the start:
example-many-services LANE BRANCH STATE SERVICES CPU MEM URL 0 main starting 14/40 468% 1.1 GiB https://example-many-services.localhost
UNIT STATE PORT CPU MEM URL api-01 ready 20590 19% 40.6 MiB https://api-01.example-many-services.localhost job-02 starting 20602 41% 40.8 MiB http://127.0.0.1:20602 web-09 queued 1/8 20618 – – http://127.0.0.1:20618 worker-09 queued 2/8 20628 – – http://127.0.0.1:20628 web-09: queued: 1 of 8 starting, CPU 94%, memory pressure normalqueued 1/8 is the unit’s place in the queue and the queue’s length. The queue is shared by the whole machine, so it counts other projects’ services too. devlanes status --output json has the numbers behind it in each queued unit’s reason: "in_flight": 20, "window": 20, "hold": "window_full".
Each starting service works in 40 ms slices, about 40% of a core, as job-02 shows above. CPU is a share of one core, so a lane can pass 100%, and the lane row adds up its units. Once all 40 are up, the lane uses about 1 core and 1.2 GiB:
LANE BRANCH STATE SERVICES CPU MEM URL 0 main running 40/40 88% 1.2 GiB https://example-many-services.localhostIn the TUI, api services are cyan, web green, workers magenta and jobs yellow (tags with color).
Try next
Section titled “Try next”Press
Min the TUI thatdevlanes startopened. The monitor shows every unit on the machine, grouped by lane, with CPU and memory graphs on top and a box under the table that graphs the selected lane.In the monitor,
/filters: typeexample-many-services joband Enter, and only units that match every word stay. Esc clears the filter.In the monitor,
<-and->move the sort through name, lane, kind, state, cpu, mem, peak and uptime,ireverses it, andeswitches to one flat list with alanecolumn.devlanes debug topprints CPU and memory per lane and unit for every lane on the machine:example-many-services@0 cpu 88% mem 1.2 GiBUNIT CPU MEMapi-01 2.0% 40.8 MiBapi-02 2.7% 41.1 MiBapi-03 2.7% 40.7 MiBdevlanes stop, thendevlanes start --no-ui --all-at-once: the gate is skipped for that run and every service starts at once. On the same 20-core Windows machine, the gated start took 10.7 to 12.3 s (3 runs) and--all-at-once6.9 to 7.3 s (3 runs), while the lane’s CPU instatuspeaked at 1088% instead of 790%. The boot here is wall-clock time; a real dev server that compiles competes for the same cores and gains less.devlanes config get startupprints the gate settings (nullmeans the default):mode: adaptiveinitial: nullmax: nulltarget_cpu: 75%settle_cpu: 10%slot_timeout: 20sreserve_memory: nullTo change them, edit
~/.devlanes/config.yamlor usedevlanes config set startup.max 8,devlanes config set startup.initial 2(ramp up from 2 slots),devlanes config set startup.mode fixed,devlanes config set startup.target_cpu 50%ordevlanes config set startup.slot_timeout 10s, anddevlanes config unset startup.maxto go back. They apply to every project on the machine.devlanes logs worker-01 --tail 4shows the bursts of a worker:worker-01#34 handled batch 2 in 295 msworker-01#35 handled batch 3 in 164 msworker-01#36 handled batch 4 in 213 msworker-01#37 handled batch 5 in 247 msnode scripts/generate.ts 12rewritesdevlanes.yamlwith 12 services (devlanes config checkaccepts it) andnode scripts/generate.tsbrings back 40. Rundevlanes stopanddevlanes startafterwards.Start a second lane:
git worktree add ../examples-checkout -b feat/checkout, thencd ../examples-checkout/showcase-many-services && devlanes start. Its index is at https://example-many-services1.localhost. In the same folder,devlanes lane new --name example-many-services-review --start --no-uigives lane 1 without a worktree:✓ installcreated example-many-services@1 named example-many-services-review (main) at D:\acme\examplesexample-many-services@1 · main✓ services 40 of 40 ready✓ index https://example-many-services1.localhost✓ api-01 https://api-01.example-many-services1.localhostBoth lanes’ 80 services go through the same gate, and the index on https://example-many-services1.localhost says
This is lane 1 of example-many-services.devlanes lane clean example-many-services-review --yesanddevlanes lane clean 0 --yesstop both lanes and free their ports.
On Windows, devlanes stop reports each service as exit=-1073741510, Windows’ exit status for a process ended by Ctrl-C.
devlanes.yaml: theinstalltask, the tags, thenode,api,web,workerandjobtemplates and 40 services. Generated; do not edit it by hand.scripts/generate.ts: writesdevlanes.yamlfromscripts/base.yaml(everything but the services);node scripts/generate.ts [count].src/index.ts: boots, listens and starts the CPU bursts for the kindKINDnames.src/kinds/: what each kind adds (api,web,worker,job).src/load.ts: the boot and the CPU bursts.