Single Complex FQL Expression vs. Multiple Sequential API Calls for Concurrent Latency
0 reputation · 06 Apr 2020, 09:27 UTC
0 reputation · 06 Apr 2020, 09:27 UTC
When designing for high-concurrency environments in FaunaDB, the deterministic ordering system based on the Calvin protocol ensures strict serializability. However, the coordination phase of the global transaction log can introduce latency variance depending on how requests are structured.
There is a design trade-off between consolidating logic into a single complex FQL expression to minimize network round-trips and breaking operations into multiple sequential API calls. While a single expression reduces network overhead, a transaction involving a large number of keys may increase the coordination burden during the commit phase.
Under heavy concurrent load, which approach typically yields more predictable response times? Does the overhead of multiple network round-trips outweigh the potential latency increase caused by large-key transactions in the coordination phase?
Under heavy concurrent load, a single complex FQL expression usually provides more predictable response times than breaking the same work into multiple sequential API calls.
The dominant source of latency variance under load is network RTT fluctuation. By consolidating work into one FQL expression you remove that per‑call jitter, leaving only the bounded commit‑phase cost. Unless the transaction touches an exceptionally large number of keys (hundreds to thousands), that commit cost remains small compared to the accumulated RTT of multiple calls.
What is the typical number of distinct keys touched per transaction in your workload? If this number is consistently above the ~100‑key threshold, the recommendation may shift toward sequential calls.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.