Skip to content

feat(backend): stream cluster stats over SSE#104

Merged
a9ex merged 3 commits into
mainfrom
feat/stream-cluster-stats-sse
Jul 4, 2026
Merged

feat(backend): stream cluster stats over SSE#104
a9ex merged 3 commits into
mainfrom
feat/stream-cluster-stats-sse

Conversation

@a9ex

@a9ex a9ex commented Jul 4, 2026

Copy link
Copy Markdown
Member

Description

Briefly describe what this PR does :

Reworks the cluster stats SSE routes to consume Docker's native stats stream instead of polling.

  • GET /clusters/:id/stats/stream now holds a single persistent Docker stats stream and forwards each sample as it arrives, instead of re-requesting stats on a timer. Interval query param is dropped for this route (Docker drives the cadence).

  • GET /clusters/stats/stream keeps one persistent stats stream open per running container, caches the latest sample per cluster, and emits the merged snapshot every N seconds. Clusters changes (started/stopped) is reconciled on the same cadence, and streams that end on their own are dropped.

  • Bumps @hallmaster/docker.js to 0.0.28 (the version exposing the streaming overload).


Context / Motivation

Explain why this change is needed:

The stats SSE routes polled Docker with stream=false on a timer. In that mode Docker "waits for 2 cycles" to compute the CPU delta before returning a single sample and disconnecting.
With exhaustMap, whenever a cycle overran the interval the following ticks were dropped, so at short intervals (e.g. 1s over several containers) the daemon couldn't keep up and the SSE cadence became erratic.


Related Links

HallMasterOrg/docker.js#20


Screenshots (if applicable)

N/A, video too big


Checklist

  • My code follows the project's coding style
  • Tests pass locally
  • I added/updated relevant tests
  • I updated documentation (if needed)
  • This PR is ready for review

Additional Notes

@a9ex a9ex merged commit dade2ef into main Jul 4, 2026
7 checks passed
@a9ex a9ex deleted the feat/stream-cluster-stats-sse branch July 4, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants