OptimizeMidBackendAuto-graded
Kill the per-post queries in a /feed endpoint
The feed issues about 1,001 queries for 500 posts; return the exact same feed with at most 3 per request.The/feed endpoint is slow under load. One request for 500 posts makes about 1,001 queries, and the count grows as posts are added. Change build_feed() so it returns exactly the same feed with at most 3 queries per request, however many posts there are. There's no database to set up: the data layer in db.py counts every query for you.30 min
python
You're done when
- A request for the 500-post feed makes at most 3 queries.
- A 50-post feed and a 500-post feed take the same number of queries, still at most 3.
What it measures
Performance optimizationFinding where the queries come from and checking the improvement by counting them.
Database administrationShaping data access so the query count stays fixed as the data grows.
Refactoring without regressionChanging how the data is fetched while keeping the response byte-identical.
Your environment
Terminal + editorA full shell in the browser
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish
Start this lab
30 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo