- Problem
- GET /api/crops returned all 2,000 crops in every status (842 KiB), and the admin orders endpoint returned all 10,000 orders (6.4 MiB). At 50 concurrent users the large responses held database pool connections until the 2-second connect timeout turned the waiting into HTTP 500s.
- Fix
- LIMIT/OFFSET pagination with total-count headers. The public listing returns listed crops only (default 20, max 100) with server-side search, filters and sort, and the web and mobile apps switched to “load more”.
- Verified
- k6, 50 users × 60 s, median of 3 on a re-seeded database: admin orders p95 20.5 s → 974 ms and errors 38.7% → 0%; crops p95 3.93 s → 455 ms and errors 47.3% → 0%.