Checkout latency regression
Project · PlatformOur checkout p99 jumped from 240ms to 1.4s after Tuesday's deploy. Here's the trace summary — where would you look first?
trace-2026-04-14.json
Three things in the trace stand out, and only one of them is likely the real cause.
- 1Serial cart repricing. Each line item now issues its own `GET /prices`. 14 items → 14 round trips at ~85ms.
- 2A new N+1 on tax rules. `tax_rules` is loaded per item instead of once per basket.
- 3Connection pool saturation. A symptom of the first two, not an independent cause.
The repricing loop is the one to fix. Batching it collapses fourteen sequential calls into one:
typescript
// before — one round trip per line item
for (const item of cart.items) {
item.price = await pricing.get(item.sku)
}
// after — a single batched lookup
const prices = await pricing.getMany(
cart.items.map((i) => i.sku)
)
for (const item of cart.items) {
item.price = prices[item.sku]
}That alone should take p99 back under 400ms. I drafted the full patch, including the tax-rule hoist, as an artifact on the right.
Atlas 4 Opus · 4.2s · 1,830 tokens
Atlas can make mistakes. Verify important details.