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.

Play the level

One call for each recordTap or press Space to batch the calls

N+1 calls · 51 calls in a row · round trips 26 ms

One batched callTap or press Space to batch the calls

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.

Case 1
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
HTTP/2UsersApp backend1 vCPU · 1 GBAPI server1 vCPU · 1 GB
GraphQLHTTP/2UsersApp backend1 vCPU · 1 GBAPI server1 vCPU · 1 GB
One call for each record: misses a goal
HTTP/2UsersApp backend1 vCPU · 1 GBAPI server1 vCPU · 1 GB
GraphQLHTTP/2UsersApp backend1 vCPU · 1 GBAPI server1 vCPU · 1 GB
One batched call: meets the goals