N+1 calls vs batched calls
An N+1 resolver makes one call for the list and one more call for each record. A batched resolver sends all record keys in one call. At 200 queries/s with 50 records each, separate calls fail 71 percent of queries. Batching gives p99 25 ms and no errors.
N+1 calls · 51 calls in a row · round trips 26 ms
Batched · 2 calls in a row · round trips 1.0 ms
Case 1
A GraphQL gateway gets 200 queries/s. Each query needs 50 records. p99 must stay below 180 ms and errors below 0.1 percent.
| Measure | Goal | One call for each record | One batched call |
|---|---|---|---|
| p99 latency | under 180 ms | 10.1 s Fail | 25 ms Pass |
| Error rate | under 0.1% | 70.9% Fail | 0% Pass |
| Monthly cost | 8 USD/mo | 8 USD/mo |