03 — Patterns

Screens assembled from the parts.

Entry flows, editorial pages and the states everybody forgets — loading, empty and error.

Sign in

Onboarding

Step 2 of 450%

Pick a region

Requests are routed to the closest healthy region. You can add more later.

Nearest
eu-west-2~18ms
us-east-1~58ms
ap-south-1~98ms

Article selection

tiles · featured + grid
All articles

Editorial

Engineering

How we cut p95 latency by 38% without touching the model

RMRui Mendes·14 August 2026 · 6 min read

Three changes did most of the work, and none of them involved the model itself. Continuous batching, speculative decoding and region-aware routing between them moved p95 from 664ms to 412ms.

Where the time actually went

Before any of this, a third of the tail was queueing — requests waiting on a batch that had already closed. Once we could admit work into a running batch, the shape of the histogram changed more than any kernel optimisation had.

The fastest request is one that never waited in line for a batch that had already left.

Continuous batching

Instead of forming a batch and running it to completion, the scheduler admits new sequences on every forward pass. Set MERIDIAN_BATCH_MODE=continuous and the rest follows.

router.ts
const region = pickRegion({
  from: request.geo,
  healthy: await health.snapshot(),
  // saturation beats distance past ~85%
  penalise: (r) => r.saturation > 0.85 ? 120 : 0,
});

The routing change is the least glamorous and the most valuable — see the Next.js routing docs for the request-level hooks we used. Outbound links in prose get their arrow automatically.

What we would do differently

  • Measure the queue before the kernel.
  • Ship the routing change first — it was a day of work.
  • Keep a per-region histogram, not a global one.

The states everyone forgets

loading · empty · error
Loading
No projects yet
Projects group deployments, keys and logs. Create one to get started.
Error