0
0
Azurecloud~5 mins

Storage redundancy (LRS, ZRS, GRS) in Azure - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Storage redundancy (LRS, ZRS, GRS)
O(n)
Understanding Time 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.

Scenario Under Consideration

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 Repeating Operations

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.
How Execution Grows With Input

Each file upload triggers copying data multiple times depending on redundancy type.

Input Size (n files)Approx. Data Copies Made
1030 (LRS), 30 (ZRS), 60 (GRS)
100300 (LRS), 300 (ZRS), 600 (GRS)
10003000 (LRS), 3000 (ZRS), 6000 (GRS)

Pattern observation: The number of copies grows linearly with the number of files uploaded.

Final Time Complexity

Time Complexity: O(n)

This means the work to store data grows directly with how many files you upload.

Common Mistake

[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.

Interview Connect

Understanding how redundancy affects work helps you design storage solutions that balance safety and speed.

Self-Check

"What if we switch from LRS to GRS? How would the time complexity and data replication change?"