Excessive round trips: Checkout went from 200 ms to 4 s after the database moved to Europe
Excessive round trips debugging lab. The orders database moved to a European region for data-residency rules. Nothing else changed, yet checkout p99 went from 200 ms to seconds.
Practice debugging a excessive round trips in a live, broken production system in your browser, with PostgreSQL. Find the root cause in the logs, terminal and code, fix it, and a load test checks that the fix holds under real traffic.
1. The Incident Context
The app servers stayed in the US, but the orders database was moved to a European region to satisfy data-residency rules. Nothing else changed. Checkout p99 went from about 200 ms to seconds. The database reports 5% CPU and no lock waits.
2. Observed Symptoms & Metrics
- Affected Endpoints / Components:
POST /checkout, the orders database, the network path between the app servers and the database.
- Behavior: Checkout p99 sits near 4 s. Orders are still written correctly; nothing is failing, just slow.
- Error Rate: Near zero. This is a latency problem, not an error problem.
- System Metrics: Database CPU is 5%, memory flat. The network round trip between the app and the database is now about 150 ms instead of under a millisecond inside the old data center.
3. Application Logs
09:41:02 checkout service listening on :8080
09:41:18 POST /checkout took 3,980ms
09:41:19 POST /checkout took 4,120ms
# pg_stat_statements (top queries by calls)
SELECT price FROM products WHERE id = $1 ← ~12 per checkout
INSERT INTO order_items ... ← ~12 per checkout
4. Your Objective
Step into the live environment while synthetic traffic is running, diagnose the root cause, and patch the codebase.
To clear this stack, your fix must satisfy these automated verification checks under a 60-second load test:
- Latency: Checkout p99 stays below 1500 ms.
- Error Rate: Fewer than 1% of requests fail.
- Data Integrity: All 100 products are still in the database.
Toolbox: curl -s -X POST localhost:8080/checkout -d '{"userId":1,"items":[{"productId":1,"quantity":1}]}' -H 'Content-Type: application/json', psql "$DATABASE_URL", the app logs.
The distance didn't change the database's speed; it changed the price of every round trip. Count the round trips one checkout makes.
Save a file in the editor to rebuild and restart the app. Click Verify when you think it's fixed.
Your account and data
You can browse stacks without an account. To run labs you sign in with your email or Google account. BustedStack uses your email address to
sign you in, and your name and profile picture to show your account and pre-fill certificates. We never access your Gmail, contacts or Drive,
sell your data or run ad trackers.
Privacy Policy · Terms of Service · Browse stacks ·
hello@bustedstack.com
This site needs JavaScript to run labs.