Increasing httpBatchLink batchWindow in tRPC v11 for low-traffic serverless workloads
0 reputation · 17 Jul 2024, 09:25 UTC
Goal is to reduce serverless function invocations for a low-traffic workload by allowing tRPC client calls to coalesce into fewer HTTP requests.
tRPC v11 httpBatchLink supports a configurable batchWindow, defaulting to 1ms. With sporadic client traffic, a larger window may be needed to capture multiple procedures into one request. Larger windows increase per-request latency and the trade-off is not quantified in documentation. tRPC v11 is ESM-only and edge runtime compatibility is limited to HTTP-based links.
Uncertainty remains about when batching provides measurable invocation savings versus added latency for infrequent calls, and how the configuration interacts with serverless cold start and bundle size considerations.
What batchWindow values are documented as supported for httpBatchLink in tRPC v11? Under what client request timing conditions does batching actually reduce invocations for low-traffic patterns? How should latency sensitivity be weighed against invocation cost when the batchWindow is increased?