Repository navigation
perf(api): right-size SSE per-subscriber channel buffer (currently hardcoded 64, untested) #152
Description
Activity
- addedenhancementNew feature or requestNew feature or requestarea/observabilityMetrics, logs, traces, health, profilingMetrics, logs, traces, health, profilingarea/apiHTTP handlers, routing, middlewareHTTP handlers, routing, middleware
on May 18, 2026 coderabbitai commented
on May 18, 2026 coderabbitaiboton May 18, 2026 – with coderabbitaiMore actions🔗 Related PRs
#124 - chore(api)!: drop hub wildcard fan-out; SSE/WS use ?table= (closes
#100) [closed]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.- Create Plan
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:issue_enrichment: auto_enrich: enabled: false
💬 Have feedback or questions? Drop into our discord!
- addedarea/docsDocumentation, site/, READMEDocumentation, site/, READMEdocumentationImprovements or additions to documentationImprovements or additions to documentation
on May 18, 2026 Dogfooding confirm (WaveHouse-Stats,
0f8826c): the hardcodedmake(chan []byte, 64)is still atinternal/api/stream.go:73(the// TODO: need to test how many are actually neededis unchanged). Filed a sibling reliability issue in the same handler — #226 (no keepalive heartbeat → idle SSE streams reset behind Cloudflare's edge ~2 min). Both touch the stream select loop, so worth fixing together.- addedarea/streamingSSE / live-query delivery path (/v1/stream)SSE / live-query delivery path (/v1/stream)
on Aug 3, 2026
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsBacklog
Problem
internal/api/stream_sse.go:51:The SSE per-subscriber channel buffer is hardcoded to 64. At ~1.6KB per slot per subscriber that's ~100KB per stream connection — fine for hundreds of subscribers, painful for thousands. More importantly: 64 is a guess, not a measurement, and the comment admits as much.
If the buffer is undersized for a real workload, the Hub drops messages to slow subscribers (existing Hub behavior); if it's oversized, memory grows linearly with concurrent subscribers.
Proposed Solution
Two parts:
WH_SSE_CHANNEL_BUFFER/server.sse_channel_buffer(default current value of 64) so operators can tune without recompiling.make dev-obswith N=10/100/1000 concurrent SSE subscribers and a realistic ingest rate, measure (a) drop rate at the Hub, (b) per-subscriber memory, (c) tail latency from publish → flush. Pick the smallest buffer that keeps drop-rate at 0 under expected alpha workloads. Document the experiment indocs/deployment.mdso operators can re-run it.Acceptance criteria
stream_sse.go:51updated or removed.Related
stream_ws.go) likely has the same parameter; check while you're in there.