Lightweight scale controller package for Mssql backend#3395
Lightweight scale controller package for Mssql backend#3395
Conversation
|
|
||
| var storageProvider = triggerMetadata.Metadata["storageProvider"] as JObject; | ||
| Assert.NotNull(storageProvider); | ||
| Assert.Equal("mssql", storageProvider["type"]?.ToString()); |
...soft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProvider.cs
Fixed
Show fixed
Hide fixed
...ure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProviderFactory.cs
Fixed
Show fixed
Hide fixed
There was a problem hiding this comment.
Pull request overview
Adds MSSQL (DurableTask.SqlServer) support to the FunctionsScale (“lightweight scale controller”) extension by introducing SQL Server-specific scalability provider components, wiring them into DI, and adding scale tests + CI coverage.
Changes:
- Implemented SQL Server scale components (provider factory/provider, metrics provider, scale monitor, target scaler).
- Registered the SQL Server scalability provider factory in the FunctionsScale extension and added the required NuGet dependency.
- Added MSSQL scale tests and updated the scale-test GitHub workflow to run SQL Server-backed tests in CI.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProviderFactory.cs |
Creates SQL Server scalability providers from trigger metadata/config; sets up orchestration service settings. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProvider.cs |
Implements ScalabilityProvider for SQL Server and exposes scale monitor/target scaler. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerMetricsProvider.cs |
Queries SQL backend for recommended replica count with a small cache. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScaleMonitor.cs |
Implements IScaleMonitor<T> for SQL-based scaling decisions. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerTargetScaler.cs |
Implements ITargetScaler for SQL Server backend recommendations. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScaleMetric.cs |
Defines the SQL scale metric payload used by monitor/scaler. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/DurableTaskScaleConfigurationExtensions.cs |
Registers the SQL Server provider factory with the extension DI. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale.csproj |
Adds Microsoft.DurableTask.SqlServer package reference. |
test/ScaleTests/Sql/SqlServerTestFixture.cs |
Shared fixture to initialize SQL task hub for tests. |
test/ScaleTests/Sql/SqlServerTestCollection.cs |
xUnit collection definition for SQL Server tests. |
test/ScaleTests/Sql/SqlServerTargetScalerTests.cs |
Integration-style tests validating target-based scaling against SQL Server. |
test/ScaleTests/Sql/SqlServerScalabilityProviderFactoryTests.cs |
Tests for factory/provider creation and basic integration behavior. |
.github/workflows/validate-build-scale.yml |
Splits ScaleTests into Azure Storage and MSSQL jobs; adds SQL Server container setup. |
Comments suppressed due to low confidence (1)
.github/workflows/validate-build-scale.yml:30
- The
steps:list items are not indented understeps:(the- uses:line is at the same indentation level). This makes the workflow YAML invalid and will prevent the job from running. Indent all step items two spaces understeps:.
steps:
- uses: actions/checkout@v3
with:
submodules: true
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProviderFactory.cs
Outdated
Show resolved
Hide resolved
...ure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProviderFactory.cs
Outdated
Show resolved
Hide resolved
...ure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProviderFactory.cs
Outdated
Show resolved
Hide resolved
...ure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProviderFactory.cs
Outdated
Show resolved
Hide resolved
...soft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProvider.cs
Outdated
Show resolved
Hide resolved
...soft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProvider.cs
Outdated
Show resolved
Hide resolved
| private readonly SqlServerMetricsProvider metricsProvider; | ||
| private int? previousWorkerCount = -1; | ||
|
|
There was a problem hiding this comment.
I don;t know why it's set to -1 but this is what we do at sql repo before https://github.com/microsoft/durabletask-mssql/blob/main/src/DurableTask.SqlServer.AzureFunctions/SqlScaleMonitor.cs#L24
...ableTask.FunctionsScale/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale.csproj
Show resolved
Hide resolved
...ure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProviderFactory.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Adds MSSQL backend support to the FunctionsScale (lightweight scale controller) package by introducing a SQL Server scalability provider (factory + provider + metrics/scaler/monitor) and validating it with new ScaleTests and CI workflow coverage.
Changes:
- Added MSSQL scalability provider implementation (factory/provider/metrics + target scaler + scale monitor/metric).
- Registered the MSSQL provider factory in DI and added the required SqlServer package reference.
- Added SQL Server scale tests (with xUnit collection fixture) and updated the scale-test GitHub Actions workflow to run MSSQL tests via Docker.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProviderFactory.cs |
Creates MSSQL scalability providers and resolves SQL connection settings. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScalabilityProvider.cs |
Implements scale monitor/target scaler creation for MSSQL. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerMetricsProvider.cs |
Fetches/caches recommended replica counts from DurableTask.SqlServer. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerTargetScaler.cs |
Implements target-based scaling using MSSQL metrics. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScaleMonitor.cs |
Implements metrics-based scaling vote logic for MSSQL. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Sql/SqlServerScaleMetric.cs |
Defines MSSQL scale metric type used by the monitor. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale.csproj |
Adds Microsoft.DurableTask.SqlServer dependency. |
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/DurableTaskScaleConfigurationExtensions.cs |
Registers the MSSQL provider factory with the Scale extension DI setup. |
test/ScaleTests/Sql/SqlServerTestFixture.cs |
Adds shared fixture to create SQL DB/schema once for MSSQL scale tests. |
test/ScaleTests/Sql/SqlServerTestCollection.cs |
Defines xUnit collection to serialize MSSQL tests and share the fixture. |
test/ScaleTests/Sql/SqlServerTargetScalerTests.cs |
Integration test validating target worker count for pending orchestrations. |
test/ScaleTests/Sql/SqlServerScalabilityProviderFactoryTests.cs |
Factory validation tests + basic integration coverage of scaler/monitor creation. |
.github/workflows/validate-build-scale.yml |
Splits scale tests into Azure Storage + MSSQL jobs; provisions SQL Server container for MSSQL runs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await Task.Delay(2000); | ||
|
|
| this.GetScaleStatusCore(context.WorkerCount, context.Metrics.Cast<SqlServerScaleMetric>()); | ||
|
|
||
| /// <inheritdoc /> | ||
| public ScaleStatus GetScaleStatus(ScaleStatusContext<SqlServerScaleMetric> context) => | ||
| this.GetScaleStatusCore(context.WorkerCount, context.Metrics); | ||
|
|
||
| private ScaleStatus GetScaleStatusCore(int currentWorkerCount, IEnumerable<SqlServerScaleMetric> metrics) | ||
| { | ||
| SqlServerScaleMetric mostRecentMetric = metrics.LastOrDefault(); |
| public virtual async Task<SqlServerScaleMetric> GetMetricsAsync(int? previousWorkerCount = null) | ||
| { | ||
| // We only want to query the metrics every 5 seconds to avoid excessive SQL queries. | ||
| if (this.metrics == null || DateTime.UtcNow >= this.metricsTimeStamp.AddSeconds(5)) | ||
| { | ||
| // GetRecommendedReplicaCountAsync will write a trace if the recommendation results | ||
| // in a worker count that is different from the worker count we pass in as an argument. | ||
| int recommendedReplicaCount = await this.service.GetRecommendedReplicaCountAsync( | ||
| previousWorkerCount, | ||
| CancellationToken.None); | ||
|
|
||
| this.metricsTimeStamp = DateTime.UtcNow; | ||
| this.metrics = new SqlServerScaleMetric { RecommendedReplicaCount = recommendedReplicaCount }; | ||
| } |
|
|
||
| - name: Start Azurite | ||
| run: azurite --silent --blobPort 10000 --queuePort 10001 --tablePort 10002 & | ||
|
|
| echo "Waiting for SQL Server to be ready..." | ||
| for i in {1..30}; do | ||
| if docker exec mssql-server /opt/mssql-tools*/bin/sqlcmd -S localhost -U sa -P "$MSSQL_SA_PASSWORD" -Q "SELECT 1" > /dev/null 2>&1; then | ||
| echo "SQL Server is ready" | ||
| break | ||
| fi | ||
| echo "SQL Server is not ready, waiting ($i/30)" | ||
| sleep 2 | ||
| done |
| /// instance, which creates the database/schema once before the first test and | ||
| /// tears it down after the last test in the collection completes. |
| using Microsoft.Azure.WebJobs.Host.Scale; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.Logging; | ||
| using Moq; |
As titled. This PR adds support for MSSQL backend at the lightweight scale controller package