Azure / Azure/azure-functions-host

Delay ShutdownChannelIfExistsAsync until cold start

Open
#9,615 0 comments 0 reactions 0 assignees View on GitHub
perf: cold-start
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

Investigate whether we can delay the code to shutdown the unused channels so that they don't impact cold start.
```csharp
if (_workerRuntime != null && rpcWorkerChannel != null)
{
bool envReloadRequestResultSuccessful = false;
if (UsePlaceholderChannel(rpcWorkerChannel))
{
_logger.LogDebug("Loading environment variables for runtime: {runtime}", _workerRuntime);
envReloadRequestResultSuccessful = await rpcWorkerChannel.SendFunctionEnvironmentReloadRequest();
}

if (envReloadRequestResultSuccessful == false)
{
_logger.LogDebug("Shutting down placeholder worker. Worker is not compatible for runtime: {runtime}", _workerRuntime);
// If we need to allow file edits, we should shutdown the webhost channel on specialization.
await ShutdownChannelIfExistsAsync(_workerRuntime, rpcWorkerChannel.Id);
}
}
_shutdownStandbyWorkerChannels();
```

The line `await ShutdownChannelIfExistsAsync(_workerRuntime, rpcWorkerChannel.Id);` - Should that be wrapped inside the "delay until cold start" utility ?

[Comment](https://github.com/Azure/azure-functions-host/pull/9602#issuecomment-1760398860) from @safihamid on #9602

> do we need to shutdown the channel immediately or can wait like 5 sec? trying to see if this will have negative cold start impact on existing apps once we switch to opt out only

Contributor guide

Open the contributing guide

Research direction

Start by locating the shown ShutdownChannelIfExistsAsync call and the delay-until-cold-start utility in the host. Review the related discussion in pull request #9602 and trace the surrounding placeholder-channel shutdown flow. Done means determining whether delaying shutdown avoids cold-start impact without harming existing apps, with tests or measurements covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, cloud, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.