I want to measure the response time as the number of instances increases to find ways to optimize provisioning.
I prepared an activity function that creates 5MB of data, as shown in the code below, but the results show no noticeable cold start.
Could you give me an example of a code that would have a larger cold start time? If possible, it would be nice if it is one that does not connect to any service other than the Azure Blob Service.
import azure.functions as func
import azure.durable_functions as df
import numpy as np
import pandas as pd
import time
# Client functions are mostly irrelevant, so some are omitted.
app = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@app.route(route="orchestrators/client_function")
@app.durable_client_input(client_name="client")
async def client_function(req: func.HttpRequest, client: df.DurableOrchestrationClient) -> func.HttpResponse:
instance_id = await client.start_new("orchestrator", None, {})
await client.wait_for_completion_or_create_check_status_response(req, instance_id)
status = await client.get_status(instance_id)
return f"runtime: {status.runtime_status}\n\noutput:\n {output_str}"
@app.orchestration_trigger(context_name="context")
def orchestrator(context: df.DurableOrchestrationContext) -> dict:
start = time.perf_counter()
activity_func = context.call_activity(f"activity{i}", size)
return time.perf_counter() - start
@app.activity_trigger(input_name="size")
def activity1(size: int) -> int:
data = np.random.rand(size)
df = pd.DataFrame(data)
df_ = df.to_dict()
return len(df_)
To induce a noticeable cold start time in an Azure Functions app without connecting to external services, you can increase the complexity of your function, for instance by introducing a time-consuming computation. Here's an example in Python using the Azure Functions Python