Azure / azure-functions-durable-extension

Durable Task Framework extension for Azure Functions
MIT License
716 stars 271 forks source link

Memory leak or wrong configuration? #2598

Open mathiasi opened 1 year ago

mathiasi commented 1 year ago

Description

First time implementing Durable Functions as we basically one HttpTrigger that might take up to 3-5 minutes to complete. Therefore we looked into the AsyncHttp pattern which seemed like what we needed. Managed to successfully implement the pattern and it functionality-wise it works. However it came to our attention that the memory consumption now seems a bit odd. As you can tell from the screenshot it is pretty clear when we made the change to Durable Functions. It even triggered a warning in App Insights about a potential memory leak. Question is now whether it is a bug, expected behavior or user-error. Using default configuration.

Expected behavior

Memory consumption to stay within range of before implementing Durable Functions

Actual behavior

Memory consumption appears to be steadily rising - even when the Durable Function isn't invoked.

Relevant source code snippets

Example of the use of AsyncHttp patttern

[FunctionName("ApproveMemberChangeRequestStart")]
public async Task<AsyncHttpResponse> ApproveChangeRequestStart([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "members-change-request/{ik}/approve")] HttpRequestMessage req, string ik, [DurableClient] IDurableOrchestrationClient starter)
{
    var userIdentity = _userService.GetUserIdentity();
    var instanceId = await starter.StartNewAsync("ApproveMemberChangeRequestOrchestrator", new ApproveChangeRequestInput(ik, userIdentity));
    return new AsyncHttpResponse(instanceId);
}

[FunctionName("ApproveMemberChangeRequestOrchestrator")]
public static async Task RunApproveChangeRequestOrchestrator([OrchestrationTrigger] IDurableOrchestrationContext context)
{
    var input = context.GetInput<ApproveChangeRequestInput>();
    try
    {
        await context.CallActivityAsync("ApproveMemberChangeRequest", input);
    } catch (Exception ex)
    {
        context.SetCustomStatus(ex.InnerException?.Message);
        throw;
    }
}

[FunctionName("ApproveMemberChangeRequest")]
public async Task ApproveChangeRequest([ActivityTrigger] ApproveChangeRequestInput input)
{
    await _changeRequestService.Approve(input.Ik, input.UserIdentity);
}

Known workarounds

None

App Details

Screenshots

image

If deployed to Azure

We have access to a lot of telemetry that can help with investigations. Please provide as much of the following information as you can to help us investigate!

If you don't want to share your Function App or storage account name GitHub, please at least share the orchestration instance ID. Otherwise it's extremely difficult to look up information.

mathiasi commented 1 year ago

I believe this is related to #2602 - it seems to be only affecting the deployment slot.