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 customers10:01GET /customers/{id}/orders p99 1.8 s10:03database CPU 84%10:04HikariPool-1: active 10/10, waiting 23
| Statement | Calls | Mean |
|---|---|---|
| select … from orders where customer_id = ? … limit 50 | 1 | 4 ms |
| select … from order_line where order_id = ? | 50 | 31 ms |
Step 1 · find it
Tap the line that causes it
Mark up to 3 lines, then check.
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.