Built‑in fetch vs custom native module: does concurrency increase latency in React Native?
0 reputation · 09 May 2025, 18:24 UTC
0 reputation · 09 May 2025, 18:24 UTC
Goal: determine if React Native's built‑in fetch API introduces higher latency when multiple requests are issued concurrently compared to a custom native networking module.
Constraints include platform‑specific connection limits per host, potential variations in JavaScript engine event‑loop behavior, and the fact that responses are handed to the JavaScript thread for sequential processing, which may serialize handling and affect perceived latency.
Key questions:
Yes, but the latency increase typically occurs at the JavaScript bridge rather than the networking layer. While the built-in fetch API leverages high-performance native stacks (OkHttp on Android and NSURLSession on iOS) that handle concurrent connections efficiently at the OS level, the bottleneck arises when those concurrent responses return.
It is important to distinguish between network-level concurrency and thread-level serialization:
fetch and custom native modules are subject to platform-specific connection limits per host. If you exceed these limits, requests will queue regardless of the implementation.fetch responses must be serialized and passed across the bridge to the single JavaScript thread. When many requests resolve simultaneously, the JS event loop must process these responses sequentially. If one response handler performs heavy computation, it creates "head-of-line blocking," increasing the perceived latency for all other pending resolutions.A custom native module can reduce latency by offloading data processing. Instead of sending raw, large JSON payloads across the bridge for JS to parse, a native module can:
This reduces the volume of data crossing the bridge and minimizes the time the JS thread spends in the serialization/deserialization phase.
To determine if the bridge is your actual bottleneck, perform the following tests:
First Byte Received (native layer) with the timestamp of the Promise Resolution (JS layer). A widening gap during concurrent loads indicates a bridge bottleneck.To provide a more specific recommendation, please specify: Are your concurrent requests returning small metadata objects or large JSON payloads? (Large payloads significantly favor custom native modules for pre-processing).
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.