Backend: GET /recorders fires unbounded concurrent Docker API + PG calls (N+1) #121

Closed
opened 2026-05-26 18:21:19 -04:00 by zgaetano · 1 comment
Owner

Fixed in 04ce096. GET /recorders now resolves live_asset_id for every recording row in a single LATERAL JOIN, and Docker container inspects are bounded to actually-recording rows and run in parallel with the existing 10 s dockerApi timeout.

Fixed in 04ce096. `GET /recorders` now resolves `live_asset_id` for every recording row in a single LATERAL JOIN, and Docker container inspects are bounded to actually-recording rows and run in parallel with the existing 10 s `dockerApi` timeout.
Author
Owner

Fix Plan — #121 GET /recorders N+1 Docker/PG calls

Root cause: recorders.js:198-202Promise.all over every recording-status recorder makes N concurrent Docker API + N concurrent PG queries. No concurrency budget. 20+ recorders → starves Docker socket + PG pool.

Fix — add p-limit:

import pLimit from "p-limit";
const limit = pLimit(4);

// before:
const statuses = await Promise.all(recorders.map(r => dockerApi("GET", `/containers/${r.container_id}/status`)));

// after:
const statuses = await Promise.all(
  recorders.map(r => limit(() => dockerApi("GET", `/containers/${r.container_id}/status`)))
);

Files: src/routes/recorders.js:198-202, package.json
Effort: ~1h
**Priority: P1 — performance

## Fix Plan — #121 GET /recorders N+1 Docker/PG calls **Root cause:** `recorders.js:198-202` — `Promise.all` over every `recording`-status recorder makes N concurrent Docker API + N concurrent PG queries. No concurrency budget. 20+ recorders → starves Docker socket + PG pool. **Fix — add p-limit:** ```js import pLimit from "p-limit"; const limit = pLimit(4); // before: const statuses = await Promise.all(recorders.map(r => dockerApi("GET", `/containers/${r.container_id}/status`))); // after: const statuses = await Promise.all( recorders.map(r => limit(() => dockerApi("GET", `/containers/${r.container_id}/status`))) ); ``` **Files:** `src/routes/recorders.js:198-202`, `package.json` **Effort:** ~1h **Priority: P1 — performance
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: WildDragonLLC/dragonflight#121
No description provided.