Performance · Cache Warmer

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.

Available onEnterprise

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

  1. Telemetry data identifies high-latency operations using P90 latency measurements. Operations are sorted by planning time.

  2. The slowest operations are compiled into a manifest and stored in the Cosmo CDN.

  3. At router startup—and after each configuration update triggered by a subgraph publish—the router fetches the manifest from the CDN.

  4. The router precomputes query plans for every operation in the manifest. Plans are stored in the cache before any traffic arrives.

  5. When the first request for a warmed operation arrives, its plan is served from cache. No planning overhead.

  6. 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`.

Automatic from telemetry. Manual override via CLI.

Cache Warmer

Before & After

Before CosmoWith Cosmo
First request for each operation pays planning overheadQuery plans ready before the first request arrives
Router restarts cause latency spikes for uncached operationsConsistent performance through restarts and config updates
Cold cache problems surface during peak traffic eventsPre-warmed cache handles traffic surges without planning delays
Manual warming scripts required for critical queriesTelemetry-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

01
P90 latency drives selection.

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.

02
CDN-backed manifest.

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.

03
Runs at startup and on update.

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.

04
Manual control via CLI.

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

Full details in the cache warmer documentation.