Storage redundancy (LRS, ZRS, GRS) in Azure - Time & Space Complexity
When storing data in the cloud, redundancy means keeping extra copies to stay safe.
We want to know how the work grows when more copies are made automatically.
Analyze the time complexity of the following operation sequence.
// Create storage account with redundancy
az storage account create --name mystorage --resource-group mygroup --location eastus --sku Standard_LRS
// Create container
az storage container create --account-name mystorage --name mycontainer
// Upload a file to storage
az storage blob upload --account-name mystorage --container-name mycontainer --name file.txt --file ./file.txt
// Repeat upload for multiple files
for file in files; do
az storage blob upload --account-name mystorage --container-name mycontainer --name "$file" --file "./$file"
done
This sequence creates a storage account with local redundancy and uploads files to it.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Uploading each file to the storage account.
- How many times: Once per file uploaded.
- Redundancy copies: LRS keeps 3 copies locally, ZRS keeps 3 copies across zones, GRS replicates to another region asynchronously.
- Dominant operation: Data replication behind the scenes for each upload.
Each file upload triggers copying data multiple times depending on redundancy type.
| Input Size (n files) | Approx. Data Copies Made |
|---|---|
| 10 | 30 (LRS), 30 (ZRS), 60 (GRS) |
| 100 | 300 (LRS), 300 (ZRS), 600 (GRS) |
| 1000 | 3000 (LRS), 3000 (ZRS), 6000 (GRS) |
Pattern observation: The number of copies grows linearly with the number of files uploaded.
Time Complexity: O(n)
This means the work to store data grows directly with how many files you upload.
[X] Wrong: "Adding redundancy does not affect upload time or work done."
[OK] Correct: More copies mean more data is written behind the scenes, so work and time increase with redundancy.
Understanding how redundancy affects work helps you design storage solutions that balance safety and speed.
"What if we switch from LRS to GRS? How would the time complexity and data replication change?"
Practice
Solution
Step 1: Understand LRS scope
LRS keeps three copies of data within a single data center to protect against hardware failures.Step 2: Compare with other options
ZRS replicates data across zones, GRS replicates across regions, so they are broader than LRS.Final Answer:
Locally Redundant Storage (LRS) -> Option DQuick Check:
Single data center copies = LRS [OK]
- Confusing ZRS with LRS because both mention redundancy
- Thinking GRS is inside one data center
- Mixing RA-GRS with LRS
Solution
Step 1: Identify valid redundancy codes
Azure uses LRS, ZRS, GRS, and RA-GRS as standard redundancy codes.Step 2: Check each option
"redundancy": "ZRS" uses "ZRS" which is valid. Others have incorrect or invalid codes.Final Answer:
"redundancy": "ZRS" -> Option AQuick Check:
Valid Azure redundancy code = ZRS [OK]
- Typos in redundancy codes like LZR or GRZ
- Using unsupported codes
- Confusing RA-GRS abbreviation
redundancy: "GRS", what happens when the primary region fails?Solution
Step 1: Understand GRS behavior
GRS replicates data asynchronously to a secondary region for disaster recovery.Step 2: Effect of primary region failure
If the primary region fails, data can be accessed from the secondary region copy.Final Answer:
Data is available from a secondary region copy -> Option CQuick Check:
GRS = secondary region copy available [OK]
- Thinking GRS only copies inside one data center
- Confusing zone redundancy with region redundancy
- Assuming data is lost on primary failure
"ZRS" but notice data is not replicated across zones. What is the likely cause?Solution
Step 1: Check ZRS regional support
ZRS requires the region to support availability zones; some regions do not support ZRS.Step 2: Understand replication behavior
If the region lacks zone support, ZRS cannot replicate across zones, causing no zone replication.Final Answer:
ZRS is not supported in the selected region -> Option BQuick Check:
ZRS needs region with zones [OK]
- Confusing GRS with ZRS replication
- Assuming LRS overrides ZRS
- Thinking ZRS replication is manual
Solution
Step 1: Analyze protection needs
Protection against data center failure requires zone or local redundancy; regional disaster needs geo-redundancy.Step 2: Balance cost and protection
LRS is cheapest but no regional protection; ZRS protects zones but not regions; GRS protects regions at moderate cost; RA-GRS adds read access but costs more.Final Answer:
Geo-Redundant Storage (GRS) -> Option AQuick Check:
Regional disaster + cost balance = GRS [OK]
- Choosing LRS which lacks regional protection
- Picking RA-GRS which costs more than needed
- Assuming ZRS protects against regional disasters
Ready to prove it?
Pass the test and this pattern moves unknown
