Skip to content

Delay ShutdownChannelIfExistsAsync until cold start #9615

@kshyju

Description

@kshyju

Investigate whether we can delay the code to shutdown the unused channels so that they don't impact cold start.

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 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions