perf(graph): warm schema cache on startup to kill cold-start spikes (#843)
Release / release (push) Failing after 59s
schemas / vulnerabilities (push) Successful in 2m34s
schemas / check (push) Successful in 2m59s
schemas / check-release (push) Successful in 3m18s
pre-commit / pre-commit (push) Successful in 6m28s
schemas / build (push) Successful in 6m20s
schemas / deploy-prod (push) Successful in 1m58s
Release / release (push) Failing after 59s
schemas / vulnerabilities (push) Successful in 2m34s
schemas / check (push) Successful in 2m59s
schemas / check-release (push) Successful in 3m18s
pre-commit / pre-commit (push) Successful in 6m28s
schemas / build (push) Successful in 6m20s
schemas / deploy-prod (push) Successful in 1m58s
This commit was merged in pull request #843.
This commit is contained in:
Vendored
+24
@@ -102,6 +102,30 @@ func (c *Cache) Services(orgId, ref, lastUpdate string) ([]string, string) {
|
||||
return services, c.lastUpdate[key]
|
||||
}
|
||||
|
||||
// OrgRef identifies a single (organizationId, ref) pair that the cache
|
||||
// tracks subgraphs for.
|
||||
type OrgRef struct {
|
||||
OrgId string
|
||||
Ref string
|
||||
}
|
||||
|
||||
// AllOrgRefs returns every (orgId, ref) pair that currently has at least
|
||||
// one subgraph in the cache. Used by startup warmup to pre-compute the
|
||||
// merged SDL and SchemaUpdate for every known ref before the pod starts
|
||||
// serving traffic.
|
||||
func (c *Cache) AllOrgRefs() []OrgRef {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
||||
var out []OrgRef
|
||||
for orgId, refs := range c.services {
|
||||
for ref := range refs {
|
||||
out = append(out, OrgRef{OrgId: orgId, Ref: ref})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (c *Cache) SubGraphId(orgId, ref, service string) string {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
||||
Reference in New Issue
Block a user