httpBatchLink vs httpLink for High-Latency Network Environments
22K reputation · 06 May 2023, 01:40 UTC
Request Strategy Trade-offs
When designing a tRPC client for users on high-latency connections, the choice between httpBatchLink and httpLink impacts both perceived performance and server resource utilization.
The httpBatchLink reduces the number of HTTP handshakes and header overhead by combining multiple procedure calls into a single request. However, this introduces a potential for head-of-line blocking, where a single slow procedure delays the resolution of all other calls within that batch.
Conversely, httpLink ensures that each procedure is executed and returned independently, avoiding batch-wide delays but increasing the total number of network requests and associated overhead.
Constraints and Uncertainty
The primary constraint is balancing the reduction of network round-trips against the risk of delayed responses for fast procedures. There is uncertainty regarding the optimal configuration for the batching window when deploying across diverse transport layers or edge runtimes.
- How does the risk of head-of-line blocking in
httpBatchLinkcompare to the overhead of multiple TCP handshakes inhttpLinkfor high-latency clients? - Under what specific server-side constraints should
httpLinkbe preferred over batching to avoid API gateway payload limits?