0
0
Azurecloud~5 mins

Blob storage (block, append, page) in Azure - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Blob storage (block, append, page)
O(n)
Understanding Time Complexity

When working with Azure Blob Storage, it's important to understand how the time to upload or modify data changes as the size or number of blobs grows.

We want to know how the number of operations or API calls increases when handling block, append, or page blobs.

Scenario Under Consideration

Analyze the time complexity of uploading data using block blobs.


// Upload a large file as blocks
var blockIds = new List<string>();
int i = 0;
foreach (var block in fileBlocks) {
  string blockId = Convert.ToBase64String(Encoding.UTF8.GetBytes(i.ToString()));
  await blobClient.StageBlockAsync(blockId, new MemoryStream(block));
  blockIds.Add(blockId);
  i++;
}
await blobClient.CommitBlockListAsync(blockIds);
    

This sequence uploads a file by splitting it into blocks, uploading each block, then committing the list to form the blob.

Identify Repeating Operations

Look at what repeats as the input grows:

  • Primary operation: Uploading each block with StageBlockAsync.
  • How many times: Once per block, so the number grows with the number of blocks.
  • Commit operation: CommitBlockListAsync runs once after all blocks upload.
How Execution Grows With Input

As the file size grows, the number of blocks increases, so the number of upload calls grows too.

Input Size (blocks)Approx. API Calls
1010 block uploads + 1 commit = 11
100100 block uploads + 1 commit = 101
10001000 block uploads + 1 commit = 1001

Pattern observation: The number of upload calls grows directly with the number of blocks.

Final Time Complexity

Time Complexity: O(n)

This means the time to upload grows linearly with the number of blocks you upload.

Common Mistake

[X] Wrong: "Uploading a large file is just one API call, so time stays the same no matter the size."

[OK] Correct: Large files are split into many blocks, each requiring a separate upload call, so time grows with file size.

Interview Connect

Understanding how upload operations scale helps you design efficient cloud storage solutions and explain your reasoning clearly in interviews.

Self-Check

What if you used append blobs instead of block blobs? How would the time complexity change when adding data?