Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MaxQueuePollingInterval default for Flex Consumption apps #2953

Merged
merged 7 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

### New Features

- Update MaxQueuePollingInterval default for Flex Consumption apps #2953

### Bug Fixes

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class AzureStorageOptions
private const int MaxTaskHubNameSize = 45;
private const int MinTaskHubNameSize = 3;
private const string TaskHubPadding = "Hub";
private TimeSpan maxQueuePollingInterval;

/// <summary>
/// Gets or sets the name of the Azure Storage connection information used to manage the underlying Azure Storage resources.
Expand Down Expand Up @@ -160,9 +161,36 @@ public string TrackingStoreConnectionStringName

/// <summary>
/// Gets or sets the maximum queue polling interval.
/// We update the default value to 1 second for the Flex Consumption SKU
/// because of a known cold start latency with Flex Consumption
/// and Durable Functions.
/// The default value is 30 seconds for all other SKUs.
/// </summary>
/// <value>Maximum interval for polling control and work-item queues.</value>
public TimeSpan MaxQueuePollingInterval { get; set; } = TimeSpan.FromSeconds(30);
public TimeSpan MaxQueuePollingInterval
{
get
bachuv marked this conversation as resolved.
Show resolved Hide resolved
{
if (this.maxQueuePollingInterval == TimeSpan.Zero)
{
if (string.Equals(Environment.GetEnvironmentVariable("WEBSITE_SKU"), "FlexConsumption", StringComparison.OrdinalIgnoreCase))
{
this.maxQueuePollingInterval = TimeSpan.FromSeconds(1);
}
else
{
this.maxQueuePollingInterval = TimeSpan.FromSeconds(30);
}
}

return this.maxQueuePollingInterval;
}

set
{
this.maxQueuePollingInterval = value;
}
}

/// <summary>
/// Determines whether or not to use the old partition management strategy, or the new
Expand Down
59 changes: 59 additions & 0 deletions test/FunctionsV2/AzureStorageOptionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Tests
{
public class AzureStorageOptionsTests
{
#if !FUNCTIONS_V1
[Fact]
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
public void MaxQueuePollingInterval_NonFlexConsumption_DefaultValue()
{
Environment.SetEnvironmentVariable("WEBSITE_SKU", "Free");

var options = new AzureStorageOptions();
Assert.Equal(TimeSpan.FromSeconds(30), options.MaxQueuePollingInterval);
}

[Fact]
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
public void MaxQueuePollingInterval_NonFlexConsumption_SetCustomValue()
{
Environment.SetEnvironmentVariable("WEBSITE_SKU", "Free");

var options = new AzureStorageOptions();
options.MaxQueuePollingInterval = TimeSpan.FromSeconds(4);
Assert.Equal(TimeSpan.FromSeconds(4), options.MaxQueuePollingInterval);
}

[Fact]
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
public void MaxQueuePollingInterval_FlexConsumption_DefaultValue()
{
Environment.SetEnvironmentVariable("WEBSITE_SKU", "FlexConsumption");

var options = new AzureStorageOptions();
Assert.Equal(TimeSpan.FromSeconds(1), options.MaxQueuePollingInterval);
}

[Fact]
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
public void MaxQueuePollingInterval_FlexConsumption_SetCustomValue()
{
Environment.SetEnvironmentVariable("WEBSITE_SKU", "FlexConsumption");

var options = new AzureStorageOptions();
options.MaxQueuePollingInterval = TimeSpan.FromSeconds(6);
Assert.Equal(TimeSpan.FromSeconds(6), options.MaxQueuePollingInterval);
}
#endif
}
}
Loading