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

Target Based Scaling for CosmosDB + Separate out CosmosDBScaleMonitor from Listener #806

Merged
merged 37 commits into from
Feb 8, 2023

Conversation

chiangvincent
Copy link
Contributor

@chiangvincent chiangvincent commented Nov 1, 2022

Overview

This PR refactors the CosmosDBTriggerListener into two components, CosmosDBScaleMonitor, and CosmosDBMetricsProvider, and introduces new class called the CosmosDBTargetScaler to support target based scaling. The refactor separates CosmosDBScaleMonitor for the redesigned scale controller, which calls into CosmosDBScaleMonitor methods for scaling decisions. This is an effort to unify scaling logic between the scale controller and extensions SDKs, which have diverged over time. The CosmosDBMetricsProvider is shared by the CosmosDBScaleMonitor and CosmosDBTargetScaler classes, which use the provider class to retrieve metrics from the monitored container.

Here is a sample PR for the Service Bus SDK for reference.

Note: this PR includes a fix for the StatusFilePath_ThrowsWhenPathDoesNotExist unit test for timer triggers after upgrading the test csproj to netcore3.1:
To address the following changes in Exception logging, see:

TODO

  • create CosmosDBScaleMonitor
  • create CosmosDBMetricsProvider
  • remove duplicate logic between CosmosDBScaleMonitor, CosmosDBMetricsProvider, and CosmosDBTriggerListener
  • CosmosDBTriggerListener implement IScaleMonitorProvider and ITargetScalerProvider
  • fix unit tests
  • add CosmosDBTargetScaler
  • add unit tests for CosmosDBTargetScaler
  • E2E tests with cosmosdb trigger
  • test with scale controller prototype

Logs from E2E Verification With Local Function App

  1. Generate a local nuget package with ComosDB changes from this PR
  2. Create function app referencing local CosmosDB nuget packages
  3. Publish and run the application locally with azure-functions-host repo
  4. Enable runtime driven scaling, target based scaling, and add ScmHostingConfigurations.txt to enable CosmosDB TBS
  5. Create timer app that sends CosmosDb events every second to a production CosmosDB container
  6. Ping admin/host/scale/status API using Postman, observe target worker count and local azure-functions-host logs emitted

Screenshot showing the target scaler requesting a worker count of 2, capped by the partition count which is 1 in this case
image

@chiangvincent chiangvincent marked this pull request as draft November 1, 2022 22:15
@chiangvincent chiangvincent changed the title Introduce Target Based Scaling and Refactor CosmosDBTriggerListener for Scale Controller Redesign Introduce Target Based Scaling in CosmosDB Trigger Listener Nov 7, 2022
@chiangvincent chiangvincent changed the title Introduce Target Based Scaling in CosmosDB Trigger Listener Introduce Target Based Scaling for CosmosDB Nov 17, 2022
Co-authored-by: Alexey Rodionov <alrod@inbox.ru>
@chiangvincent chiangvincent changed the title Introduce Target Based Scaling for CosmosDB Introduce Target Based Scaling for CosmosDB + Make ScaleMonitor and TargetScaler public for use Redesigned Scale Controller Jan 13, 2023
@chiangvincent chiangvincent changed the title Introduce Target Based Scaling for CosmosDB + Make ScaleMonitor and TargetScaler public for use Redesigned Scale Controller Introduce Target Based Scaling for CosmosDB + Make ScaleMonitor and TargetScaler public for use in Redesigned Scale Controller Jan 13, 2023
@chiangvincent chiangvincent changed the title Introduce Target Based Scaling for CosmosDB + Make ScaleMonitor and TargetScaler public for use in Redesigned Scale Controller Introduce Target Based Scaling for CosmosDB Jan 18, 2023
@chiangvincent chiangvincent changed the title Introduce Target Based Scaling for CosmosDB Introduce Target Based Scaling for CosmosDB + Separate out CosmosDBScaleMonitor from Listener Jan 18, 2023
@chiangvincent chiangvincent changed the title Introduce Target Based Scaling for CosmosDB + Separate out CosmosDBScaleMonitor from Listener Target Based Scaling for CosmosDB + Separate out CosmosDBScaleMonitor from Listener Jan 30, 2023
Copy link
Member

@ealsur ealsur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on the trigger changes

@chiangvincent
Copy link
Contributor Author

@ealsur are the scale monitors used for Cosmos V3 the same ones here? If not, can you send a pointer to the existing listener + scale monitor we will have to cherry-pick to?

@chiangvincent chiangvincent marked this pull request as ready for review February 7, 2023 15:00
@ealsur ealsur merged commit 462fe04 into dev Feb 8, 2023
@ealsur ealsur deleted the user/vchiang/cosmosDbTbs branch February 8, 2023 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants