Uncompressed responses: Reports API is fast in the office but slow for overseas customers
Uncompressed responses debugging lab. The reports API returns in 120 ms from the office next to the data center and 6 s for customers in Asia. The server says every request finishes in 40 ms. The bodies are ~9 MB of JSON.
Practice debugging a uncompressed responses 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
GET /reports/sales takes 120 ms from the office next to the data center and about 6 s for customers in Asia. The server log says every request finishes in 40 ms. The response bodies are ~9 MB of JSON.
2. Observed Symptoms & Metrics
- Affected Endpoints / Components:
GET /reports/sales, the network link to overseas customers.
- Behavior: The server does its work in 40 ms. The rest of the time goes into pushing 9 MB of JSON over a slow, far-away link (9 MB at 2 MB/s is about 4.5 s).
- Error Rate: Zero. This is a transfer-time problem, not a correctness problem.
- System Metrics: Server CPU is low. The bytes written per request are the problem.
3. Application Logs
15:30:02 reports service listening on :8080
15:30:40 GET /reports/sales served in 40ms
15:30:41 GET /reports/sales wrote 9,000,000 bytes
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 over a link limited to 2 MB/s:
- Latency: P99 stays below 1500 ms for clients that accept gzip.
- Compatibility: Clients that don't send
Accept-Encoding still get plain JSON.
Toolbox: curl -s -H 'Accept-Encoding: gzip' localhost:8081/reports/sales | wc -c, curl -s localhost:8081/reports/sales | wc -c, the app logs.
JSON is very repetitive, so it compresses about 10x. Compress when the client accepts gzip and leave plain JSON for everyone else.
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.