High TTFB and execution latency on Astro SSR routes despite fast app code

Problem

We’re seeing intermittent 3–7s TTFB execution time on SSR admin routes. We’ve instrumented our middleware and handlers, and the app code is consistently fast (~100–400ms). The spikes appear to happen before the function starts executing.

Evidence

  • Response headers show low app time:
    • X-App-Timing: total ~120–460ms
    • X-Instance-Uptime: high (e.g. 100–200s) → not a cold start
  • Yet browser TTFB is 3–7s for the same request.
  • Running the same app on a cheap Hetzner VPS (always‑on Node) eliminates the spikes entirely.

Example response headers:

x-app-timing: admin_start;dur=0.15 … total;dur=123ms  
x-instance-uptime: 185s  
x-vercel-cache: MISS

What we tested

  1. Verified API calls are fast (100–200ms).
  2. Added server timing headers and measured hydration; hydration is <1s.
  3. Cached stats endpoint for 10 minutes to reduce load (no change in spikes).
  4. cURL tests show the same URL can be 7s then 0.6s next run.
  5. VPS test shows no long tails.

Environment

  • Framework: Astro SSR
  • Adapter: @astrojs/vercel
  • Compute: Fluid compute, hot function

Question

Any suggestions on reducing the pre‑execution latency spikes? Happy to share x-vercel-id values if helpful.

Hey @ninuzibz, welcome to the community! Saw you posted in Reddit as well.

Here are some previous community posts which may be helpful with debugging:

Did you notice a change in this pattern after recent changes, or has it happened since deploying to Vercel?