0
0
Azurecloud~5 mins

Purging CDN cache in Azure - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Purging CDN cache
O(1)
Understanding Time Complexity

When we purge a CDN cache, we ask the system to remove stored copies of content so fresh content can be served.

We want to know how the time to complete this purge changes as we ask to clear more items.

Scenario Under Consideration

Analyze the time complexity of the following operation sequence.


// Purge multiple CDN paths
var cdnClient = new CdnManagementClient(credentials);
var purgeContentPaths = new List<string> { "/images/*", "/css/*", "/js/*" };
await cdnClient.Endpoints.PurgeContentAsync(
    resourceGroupName, profileName, endpointName, purgeContentPaths);
    

This code sends a request to purge multiple paths from the CDN cache at once.

Identify Repeating Operations

Identify the API calls, resource provisioning, data transfers that repeat.

  • Primary operation: One API call to purge multiple paths.
  • How many times: The purge API is called once per purge request, regardless of number of paths.
How Execution Grows With Input

Adding more paths to purge does not increase the number of API calls, but may increase the request size slightly.

Input Size (n)Approx. Api Calls/Operations
101 API call
1001 API call
10001 API call

Pattern observation: The number of API calls stays the same even as the number of paths grows.

Final Time Complexity

Time Complexity: O(1)

This means the time to send the purge request does not grow with the number of paths purged.

Common Mistake

[X] Wrong: "Purging more paths means more API calls and longer time."

[OK] Correct: The purge API accepts multiple paths in one call, so the number of calls stays the same regardless of paths.

Interview Connect

Understanding how cloud APIs handle batch operations helps you design efficient systems and answer questions about scaling in real projects.

Self-Check

"What if we purged each path with a separate API call? How would the time complexity change?"