perf(graph): warm schema cache on startup to kill cold-start spikes #843
Reference in New Issue
Block a user
Delete Branch "warm-schema-cache-on-startup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Following the schema cache PR (#841), warm pods serve from cache. New pods start cold: the first LatestSchema query per (orgId, ref) runs wgc router compose (100-300m CPU). That keeps tripping the HPA into TooManyReplicas — HPA scales up → new cold pod → wgc spike → scales up more. Production observed pods cycling 2→4→2→4 with cpu 1%/60%, fresh pods showing 2 cold computes within their first minute.
Fix: add Cache.AllOrgRefs() and Resolver.WarmCache(ctx). Service startup calls WarmCache right after the Resolver is wired, before the HTTP server accepts traffic. The first LatestSchema query a pod receives is now a cache hit. Pod start time grows by roughly N x cosmo-compose latency.