Skip to content

SSE cold cache stampede spawns one Kubernetes API call per concurrent user with no singleflight coalescing #7045

@aashu2006

Description

@aashu2006

User Request

Type: bug
Target: Console Application
Submitted by: @aashu2006
Console Request ID: 5f18de6d-b14d-4174-a538-53ed991f19a6

Description

What happened:
In pkg/api/handlers/sse.go:420-433, when the cache is cold, every concurrent SSE request for the same cluster spawns a goroutine that independently calls the Kubernetes API. All of them succeed and all call sseCacheSet with only the last write winning. Under bursty traffic (page loads after deploy), this multiplies Kubernetes API calls by the number of concurrent users.

What I expected:
golang.org/x/sync/singleflight should be used keyed on cacheKey to coalesce concurrent cold fetches into a single Kubernetes API call.

Steps to reproduce:

  1. Clear the SSE cache
  2. Send 50 concurrent requests for the same cluster resource
  3. Observe 50 Kubernetes API calls instead of one

This issue was automatically created from the KubeStellar Console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-fix-requestedai-processingAI is currently processing this issuekind/bugCategorizes issue or PR as related to a bug.triage/acceptedIndicates an issue or PR is ready to be actively worked on.triage/neededNeeds triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions