Function execution model in Azure - Time & Space Complexity
When using Azure Functions, it is important to understand how the time to execute grows as more function calls happen.
We want to know how the system handles many requests and how the execution time changes.
Analyze the time complexity of the following Azure Function invocation pattern.
// Azure Function triggered by HTTP requests
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("Function processed a request.");
string name = req.Query["name"];
return new OkObjectResult($"Hello, {name}");
}
This function runs once per HTTP request, processing input and returning a response.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Each HTTP request triggers one function execution.
- How many times: The function runs once per request, so the number of executions equals the number of requests.
As the number of requests increases, the total function executions increase at the same rate.
| Input Size (n) | Approx. Function Executions |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: The total executions grow linearly with the number of requests.
Time Complexity: O(n)
This means the total execution time grows directly in proportion to the number of function calls.
[X] Wrong: "The function execution time stays the same no matter how many requests come in."
[OK] Correct: While each function runs independently, the total time to handle all requests grows as more requests arrive.
Understanding how function executions scale helps you design systems that handle growing workloads smoothly and predict performance.
"What if the function triggers other functions internally? How would the time complexity change?"