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?"