Skip to content
Chaos Lab

Debug the code · lab 1 · starter · about 6 min

The order history page

At 09:58 the shop emailed 400,000 customers a link to their order history. The page lists a customer's last 50 orders, with how many items each had and the total. By 10:01 its p99 is 1.8 seconds and the database is at 84% CPU. Nothing was deployed today.

  • Your fix must
  • At most 3 queries per page view
  • p99 under 250 ms during the email peak
  • Never loads more than 50 orders into memory
  • A new order shows on the next page view
Order history p991.84 starget < 250 ms

Pager timeline

Logs and signalsReconstructed
09:58campaign 'Your year in orders' sent to 400,000 customers
10:01GET /customers/{id}/orders p99 1.8 s
10:03database CPU 84%
10:04HikariPool-1: active 10/10, waiting 23
Hibernate statistics · one page view
StatementCallsMean
select … from orders where customer_id = ? … limit 5014 ms
select … from order_line where order_id = ?5031 ms

Step 1 · find it

Tap the line that causes it

Mark up to 3 lines, then check.

OrderHistoryController.javaJava 21 · Spring Boot 3 · JPA

No line marked yet

The code is real Spring Boot; the evidence and every patch's numbers are simulated and illustrative. Nothing runs in your browser.