Skip to content

coderd: implement autoscaling mechanism #312

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

Open
dannykopping opened this issue Jan 23, 2025 · 0 comments
Open

coderd: implement autoscaling mechanism #312

dannykopping opened this issue Jan 23, 2025 · 0 comments

Comments

@dannykopping
Copy link
Collaborator

dannykopping commented Jan 23, 2025

Relates to #311 and #304:

Given that prebuilt instances will be consuming (potentially very expensive) cloud resources, operators will need a mechanism to scale down (or to 0) when not needed.

We can expose an autoscaling field under coder_workspace_preset:

data "coder_workspace_preset" "us-nix" {
  ...
  
  prebuilds = {
	  instances = 0                  # default to 0 instances
	  
	  autoscaling = {
		  timezone = "UTC"             # only a single timezone may be used for simplicity
		  
		  # scale to 3 instances during the work week
		  schedule {
		    cron = "* 8-18 * * 1-5"    # from 8AM-6PM, Mon-Fri, UTC
		    instances = 3              # scale to 3 instances
		  }
		  
		  # scale to 1 instance on Saturdays for urgent support queries
		  schedule {
		    cron = "* 8-14 * * 6"      # from 8AM-2PM, Sat, UTC
		    instances = 1              # scale to 1 instance
		  }
	  }
  }
}

The solution above is designed to mirror the autostart scheduling.

The crontab format will already be familiar to operators, and will be intuitive to understand. The design above allows operators to specify a default number of instances, and then to scale that number dynamically based on one or more schedules. This can either be used to start from 0 and scale up (as the example above demonstrates), or the inverse; whichever the operator prefers.

This design would also allow for validation at template import time, where we will detect scheduling conflicts (i.e. if multiple schedules overlap and produce different values).

This will require a simple ticker to evaluate when the current time matches the crontab expression of a schedule, and to trigger the appropriate reconciliation in the reconciliation loop.

@dannykopping dannykopping added the stretch Stretch goal label Jan 23, 2025
@coder-labeler coder-labeler bot added the help wanted Extra attention is needed label Jan 23, 2025
@dannykopping dannykopping removed help wanted Extra attention is needed stretch Stretch goal labels Jan 23, 2025
@dannykopping dannykopping changed the title coderd: implement basic autoscaling mechanism coderd: implement autoscaling mechanism May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant