feat(backend): stream cluster stats over SSE#104
Merged
Conversation
Ximaz
approved these changes
Jul 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/streamnow 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/streamkeeps 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.jsto0.0.28(the version exposing the streaming overload).Context / Motivation
Explain why this change is needed:
The stats SSE routes polled Docker with
stream=falseon 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
Additional Notes