Storage tier optimization in Azure - Time & Space Complexity
Start learning this pattern below
Jump into concepts and practice - no test required
When we optimize storage tiers, we want to know how the time to move or access data changes as the amount of data grows.
We ask: How does the work increase when we handle more files or data size?
Analyze the time complexity of the following operation sequence.
// Move blobs from hot to cool tier based on last access date
var blobs = container.ListBlobs();
foreach (var blob in blobs) {
if (blob.Properties.LastAccessed < DateTime.UtcNow.AddDays(-30)) {
blob.SetTier(AccessTier.Cool);
}
}
This code checks each blob in a storage container and moves older blobs to a cooler, cheaper storage tier.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Checking each blob's last access date and setting its storage tier.
- How many times: Once for every blob in the container.
As the number of blobs grows, the number of checks and possible tier changes grows too.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | About 10 checks and possible tier changes |
| 100 | About 100 checks and possible tier changes |
| 1000 | About 1000 checks and possible tier changes |
Pattern observation: The work grows directly with the number of blobs.
Time Complexity: O(n)
This means the time to optimize storage tiers grows in a straight line as the number of blobs increases.
[X] Wrong: "Changing storage tiers happens instantly for all blobs at once."
[OK] Correct: Each blob must be checked and updated individually, so time grows with the number of blobs.
Understanding how operations scale with data size helps you design efficient cloud solutions and shows you think about real-world costs and delays.
"What if we batch update blobs instead of updating one by one? How would the time complexity change?"
Practice
Solution
Step 1: Understand storage tiers purpose
The Hot tier is designed for data accessed frequently, providing low latency and high throughput.Step 2: Match access frequency to tier
Since the question asks for very often access, Hot tier fits best compared to Cool (infrequent) or Archive (rare).Final Answer:
Hot tier -> Option CQuick Check:
Frequent access = Hot tier [OK]
- Confusing Cool tier as best for frequent access
- Choosing Archive tier for active data
- Thinking Premium tier is a storage tier
Solution
Step 1: Recall correct Azure CLI syntax
The correct command to set a blob's tier isaz storage blob set-tierwith parameters for tier, container, blob name, and account.Step 2: Verify az storage blob set-tier --tier Cool --container-name mycontainer --name myblob --account-name mystorage matches syntax
az storage blob set-tier --tier Cool --container-name mycontainer --name myblob --account-name mystorage usesset-tierand correct parameter names, matching Azure CLI documentation.Final Answer:
az storage blob set-tier --tier Cool --container-name mycontainer --name myblob --account-name mystorage -> Option BQuick Check:
Correct CLI command = az storage blob set-tier --tier Cool --container-name mycontainer --name myblob --account-name mystorage [OK]
- Using incorrect command verbs like update-tier
- Wrong parameter names like --container instead of --container-name
- Mixing blob and container parameters
az storage blob set-tier --tier Archive --container-name logs --name log1.txt --account-name mystorageWhat happens to the blob
log1.txt after this command?Solution
Step 1: Understand Archive tier behavior
Setting a blob to Archive tier moves it to a low-cost, offline storage. It cannot be read until rehydrated.Step 2: Analyze command effect
The command sets the tier to Archive, so the blob becomes offline and inaccessible until restored.Final Answer:
Blob is moved to Archive tier and becomes offline until rehydrated -> Option DQuick Check:
Archive tier = offline storage [OK]
- Thinking Archive tier deletes the blob
- Assuming blob stays accessible immediately
- Confusing Archive with Hot tier
az storage blob set-tier --tier Hot --container-name data --name file1.csv --account-name mystorageBut you get an error saying the blob does not exist. What is the most likely cause?
Solution
Step 1: Understand error meaning
An error stating the blob does not exist usually means the blob or container name is wrong or the blob was deleted.Step 2: Check other options
Account name errors usually give different messages; Hot tier is valid; CLI outdated causes different errors.Final Answer:
The blob name or container name is incorrect -> Option AQuick Check:
Blob not found = wrong name [OK]
- Assuming tier Hot is invalid
- Blaming CLI version without checking names
- Ignoring typo in blob or container names
Solution
Step 1: Understand tier cost and access trade-offs
Hot tier is expensive but fast, Cool is cheaper for infrequent access, Archive is cheapest but offline.Step 2: Apply tier optimization best practice
Using Hot for frequent, Cool for infrequent, and Archive for rare access balances cost and performance.Final Answer:
Store frequently accessed data in Hot tier, infrequent in Cool, and rarely accessed in Archive -> Option AQuick Check:
Tier data by access frequency = Store frequently accessed data in Hot tier, infrequent in Cool, and rarely accessed in Archive [OK]
- Putting all data in Hot tier wastes money
- Never rehydrating Archive data makes it unusable
- Using only Cool tier ignores access patterns
