Cache Warmer for Federated GraphQL | Cosmo by WunderGraph - WunderGraph
Query plans ready before the first request arrives.
Telemetry identifies your slowest operations by P90 latency. Cosmo compiles them into a manifest and precomputes their query plans at router startup—before any traffic reaches the cache.
The problem
Every restart starts with an empty cache
The query plan cache is in-memory. Restarts, deployments, and config updates clear it. The first requests after each restart pay the full planning cost.
Router restarts clear the query plan cache
Every deployment or config update restarts the router. The query plan cache starts empty, so the first execution of each operation pays the full planning cost.
First requests pay planning overhead
Building an optimized query plan for a federated operation takes time. Under normal load this is invisible. Under peak traffic the delay reaches users.
Peak traffic events expose cold cache problems
Flash sales, live broadcasts, and marketing campaigns bring sudden traffic spikes. A cold cache at the start of a high-traffic event causes latency exactly when it matters most.
Our solution
Telemetry-driven, pre-startup warming
The Cache Warmer uses real traffic data to identify which operations need warming. Plans are precomputed before any request arrives, so cold-start latency is eliminated from the first call after every restart.
How Cache Warmer works
- Telemetry data identifies high-latency operations using P90 latency measurements. Operations are sorted by planning time.
- The slowest operations are compiled into a manifest and stored in the Cosmo CDN.
- At router startup—and after each configuration update triggered by a subgraph publish—the router fetches the manifest from the CDN.
- The router precomputes query plans for every operation in the manifest. Plans are stored in the cache before any traffic arrives.
- When the first request for a warmed operation arrives, its plan is served from cache. No planning overhead.
- Operations are managed with a LIFO (Last-In, First-Out) policy up to a configurable maximum. Add specific operations manually with
wgc router cache push.
Before & After
| Before Cosmo | With Cosmo |
|---|---|
| First request for each operation pays planning overhead | Query plans ready before the first request arrives |
| Router restarts cause latency spikes for uncached operations | Consistent performance through restarts and config updates |
| Cold cache problems surface during peak traffic events | Pre-warmed cache handles traffic surges without planning delays |
| Manual warming scripts required for critical queries | Telemetry-driven automatic warming with manual override via CLI |
Configuration
Enable in router config
cache_warmup:
enabled: true
telemetry:
metrics:
attributes:
- key: "wg.operation.hash"
value_from:
context_field: operation_hash
Requires Enterprise plan. Activate at the namespace level in Cosmo Studio.
How Cache Warmer works in Cosmo
Identify
Telemetry measures P90 latency for each operation. Operations with the highest planning times are selected for warming. Only slow-to-plan operations are targeted.
Build manifest
The slowest operations are compiled into a manifest stored in the Cosmo CDN. The manifest is updated when operations are added or removed.
Precompute
At router startup and after each config update, the router fetches the manifest and precomputes query plans. Plans are written to the cache before any request arrives.
Override
Add specific operations to the manifest manually with wgc router cache push. Critical queries that may not appear frequently enough to rank by P90 can be forced into the warming list.
Capabilities
Telemetry-driven, manually overridable
P90 prioritization. LIFO management. CLI control. In-memory fallback.
P90-based prioritization
Operations are selected by P90 planning latency. Only operations that are slow to plan are included in the warm-up manifest.
LIFO operation management
Operations are managed with a Last-In, First-Out policy up to a configurable maximum. When the limit is reached, the oldest entry is removed when a new one is added.
Manual CLI override
Push specific operations to the warming manifest with wgc router cache push. Useful for business-critical queries that may not appear frequently enough to rank by P90.
In-memory fallback
The slow plan cache preserves query plans with planning times above a configurable threshold (default 100ms) across hot config reloads and schema changes, providing a local fallback when the CDN manifest is unavailable.
Eliminate cold-start latency from your federated graph
Cache Warmer is available on Enterprise. Contact us to discuss your deployment.
FAQ
Cache Warmer on Cosmo Router
- Which operations get warmed?
- When does warming occur?
- What is the in-memory fallback?
- How do I configure the warmup throughput?
- What telemetry is required?
- Does Cache Warmer require an Enterprise plan?
Full details in the cache warmer documentation.