The Real Fullstack

The Slow Checkout Trace

Frontend blames the API, the API blames the database, the database blames the network. The trace disagrees with all of them.

架构师15 分钟调试实验室性能实验室流程模拟器
opentelemetryangularspring-bootpostgresql

此挑战尚未翻译为简体中文,你正在阅读英文版本。

任务:Read the trace end to end, name the root cause, and fix every layer the trace points to without papering over it with caches.背景 · 学习目标 ▾

Hollow Basket's checkout page takes 6.8 s. An OpenTelemetry trace covers the browser, gateway, cart API and PostgreSQL. Each team has a favourite fix — a bigger cache, more replicas, a CDN — but nobody has read the whole trace.

任务: Read the trace end to end, name the root cause, and fix every layer the trace points to without papering over it with caches.

学习目标

  • Use a distributed trace to follow one request across layers.
  • Fix N+1 queries and the missing index they hit.
  • Parallelise independent frontend requests and split heavy bundles.
模拟模拟数据
shopperAngular SPAAPI gatewaycart APIPostgreSQLtracing backend
运行模拟
@Query("select c from Cart c join fetch c.items i join fetch i.product where c.id = :id")Optional<Cart> findWithItems(@Param("id") long id);      // 1 query instead of 1 + 87