Replica lag trade‑off in Azure SQL Database read‑scale‑out
0 reputation · 15 May 2021, 21:48 UTC
0 reputation · 15 May 2021, 21:48 UTC
The goal is to understand how acceptable replica lag should be balanced against reduced primary latency when using Azure SQL Database’s read‑scale‑out feature to offload heavy read workloads.
Constraints include the chosen service tier, the size and type of read‑only secondary, and the latency tolerance of the application consuming the replicated data. The read‑scale‑out feature allows reads to be served from a secondary replica, but the replica lag is workload‑dependent and not guaranteed by a fixed SLA.
Uncertainty arises because replica lag can vary with query mix, data change rate, and network conditions, making it difficult to predict the exact delay that will be incurred for a given concurrent load.
What is the maximum replica lag that can be tolerated for a latency‑sensitive application before read‑scale‑out becomes counter‑productive? How can we quantify the trade‑off between primary latency reduction and secondary replica lag across different service tiers? Are there recommended thresholds or monitoring practices to decide when to switch between primary and secondary reads?
35275 reputation · 15 May 2021, 23:41 UTC
The replica lag that can be tolerated is the amount of extra latency your application can accept on a read. If the observed lag exceeds that tolerance, reading from the secondary adds more delay than reading from the primary, making read‑scale‑out counter‑productive.
sys.dm_geo_replication_link_status (column replication_lag_sec).Effective latency when reading from the secondary is:
EffectiveLatency = Ls + Lg
Read‑scale‑out is beneficial only when:
EffectiveLatency < Lp
Re‑arranging gives the maximum tolerable lag:
Lg,max = Lp - Ls + ToleratedExtraLatency
Since Ls ≈ Lp in the same tier, the formula simplifies to:
Lg,max ≈ ToleratedExtraLatency
Thus, the lag you can allow is essentially the extra latency your application can tolerate.
Application Intent=ReadWrite and capture average execution time via Query Performance Insight or extended events.Application Intent=ReadOnly (or connect to the secondary directly) and record average latency.sys.dm_geo_replication_link_status.To compute a concrete threshold, we need the maximum additional read latency your application can tolerate. Please provide that value (e.g., "our reads may be up to 30 ms slower than primary reads") so a specific lag alert threshold can be defined.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.