Announcing CosmosDB Scheduler

One of the great features and selling points of CosmosDB is the elasticity and scale it provides. As we know it does that via the Request Units per second (RUs) that you provision at your collection or database level and that is an indication of your compute capacity as well as cost. The other particularity of this model is that it is a provision based model which means you pay for what you request regardless of how much of it you consume. This often leads to overpaying for resources you never use especially in dev or testing environments as well as in workloads that have a very predictable loads (an app for a store that is closed at night).

The solution

Because making changes to the provisioned RUs is a a very simple and quick operation available though the SDKs I decided to build a simple application that allows you to schedule the scale of your CosmosDB collections based on your known patterns -> say hello to Cosmos Scheduler.

One of the most basic scenarios that I’ve used this mini-app for is to scale down all dev collections at the end of the day because let’s be honest, devs will be devs and will always forget to scale it down after they worked on it.

Implementation

THe solution is comprised of a few simple components, and I tried to keep everything serverless:

  • A set of Azure Function that handle the recurring timers and initiate the scale operations
  • A simple React WebApp hosted statically in a storage account and served via Azure Functions proxies
  • A storage account for the application data, queues of operations and actual webapp files.

How to use it

You can find the entire solution on GitHub. There’s two ways to get started with it, you can either use the “one-click” deployment powershell script and deploy an instance in your environment or you can fork the repository and use the Azure DevOps and the provided build and deploy yaml files to create a full CI/CD environment.

Looking forward to your feedback and maybe even contributions on GitHub

Share Comments