0

Running the simple hello world code below takes an average of 8 seconds to execute (200 samples, Minimum 64ms, max 14 seconds using jmeter).

I do not see app stops in the logs so why so long and why such a variance?

Note I've tried from multiple network connections, internal and external so doesn't appear network related.

public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string name = req.Query["name"];

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            name = name ?? data?.name;

            string responseMessage = string.IsNullOrEmpty(name)
                ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
                : $"Hello Universe, {name}. This HTTP triggered function executed successfully.";

            return new OkObjectResult(responseMessage);
        }
    }

Log file doesn't show anything unusual:

2020-11-19T13:44:40.502 [Information] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=47ae5039-ac8a-4146-8f06-76b74bafae42)
2020-11-19T13:44:40.540 [Information] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=5e51999c-c255-44c8-b155-0ea5248d0621)
2020-11-19T13:44:40.541 [Information] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=bcb087b3-2dae-4514-9821-34971d1e816e)
2020-11-19T13:44:40.541 [Information] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=90ce4f95-8f34-4359-8bb6-d11b56198edd)
2020-11-19T13:44:40.547 [Information] C# HTTP trigger function processed a request.
2020-11-19T13:44:40.569 [Information] C# HTTP trigger function processed a request.
2020-11-19T13:44:40.570 [Information] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=edd086c6-b5ad-43f1-855c-5dd729812e3a)
2020-11-19T13:44:40.570 [Information] C# HTTP trigger function processed a request.
2020-11-19T13:44:40.575 [Information] C# HTTP trigger function processed a request.
2020-11-19T13:44:40.622 [Information] Executed 'Function1' (Succeeded, Id=5e51999c-c255-44c8-b155-0ea5248d0621, Duration=76ms)
2020-11-19T13:44:40.699 [Information] C# HTTP trigger function processed a request.
2020-11-19T13:44:40.700 [Information] Executed 'Function1' (Succeeded, Id=edd086c6-b5ad-43f1-855c-5dd729812e3a, Duration=129ms)
2020-11-19T13:44:40.701 [Information] Executed 'Function1' (Succeeded, Id=bcb087b3-2dae-4514-9821-34971d1e816e, Duration=160ms)
2020-11-19T13:44:40.702 [Information] Executed 'Function1' (Succeeded, Id=90ce4f95-8f34-4359-8bb6-d11b56198edd, Duration=160ms)
2020-11-19T13:44:40.712 [Information] Executed 'Function1' (Succeeded, Id=47ae5039-ac8a-4146-8f06-76b74bafae42, Duration=230ms)

  • Is it possible that your Azure Function is experiencing lag time from "[cold starts](https://markheath.net/post/avoiding-azure-functions-cold-starts)"? TL;DR - you may have to use a "warmup request", upgrade the associated App Service Plan, and/or upgrade to an Azure Functions Premium Plan. – esqew Nov 19 '20 at 15:30
  • Does this answer your question? [Why do Azure Functions take an excessive time to "wake up"?](https://stackoverflow.com/questions/45448040/why-do-azure-functions-take-an-excessive-time-to-wake-up) – esqew Nov 19 '20 at 15:31
  • Per the logs, the App isn't waking up or going to sleep – jumpstracks Nov 19 '20 at 18:40

1 Answers1

0

Turned out the VS2019 wizard additionally publishes a blob storage trigger and was failing repeatedly very often and causing a drain on server resources.