Configure scaling

Configure scaling settings to manage the performance and cost of your Managed DevOps Pool. For information on pricing and performance, see Manage cost and performance.

Agent state

Managed DevOps Pools can be configured as stateless or stateful.

The default setting for a Managed DevOps pool is stateless (Fresh agent every time) but in some cases teams might want to reuse agents in order to reuse the packages or files created during the previous pipeline run. Build workload is a common scenario where teams want to preserve state and reuse agents. You can achieve stateful pools through Managed DevOps Pools while balancing it with security best practices. By default an agent can be reused for a maximum of 7 days but you can configure it to be recycled sooner.

Note

Stateless pools or use of the agent state setting Fresh agent every time are recommended by security experts as a defense against supply chain attacks.

Stateless pools

When a stateless agent is configured, a new agent is procured for each job, and is discarded after the job completes.

Screenshot of a stateless agent.

When Agent state is set to Fresh agent every time, a new agent is procured for each job, and is discarded after the job completes.

Stateful pools

Screenshot of a stateful agent.

When Same agent can be used by multiple builds ("kind": "stateful" in resources templates or { "stateful": {...} } in Azure CLI) is enabled, agents in the pool are considered to be stateful. Stateful pools are configured using the following settings.

  • Max time to live for standby agents (maxAgentLifetime) configures the maximum duration an agent in a stateful pool can run before it is shut down and discarded. The format for Max time to live for standby agents is dd.hh:mm:ss. The default value of Max time to live for standby agents is set to the maximum allowed duration of seven days (7.00:00:00).

  • Grace Period (gracePeriodTimeSpan) configures the amount of time an agent in a stateful pool waits for new jobs before shutting down after all current and queued jobs are complete. The format for Grace Period is dd.hh:mm:ss and the default is no grace period.

While agents in stateless pools are shut down and discarded after every job, agents in stateful pools continue running if any of the following conditions are met.

  • If there is another job queued when the first job completes, Managed DevOps Pools sends that job to the agent that ran the first job instead of shutting it down.
  • If there is a grace period configured for the pool, agents wait for new jobs for the duration specified by the grace period before shutting down.
  • If standby agents are enabled, and the agent image meets the criteria of the active provisioning period, the agent continues to run and wait for jobs.

Running agents in stateful pools are shut down and discarded if they run continuously for the duration specified by Max time to live for standby agents, even if the previous conditions are true. For example, if Max time to live for standby agents is configured for three days, and Standby agent mode is set to Manual, All Week Scheme (Machines available 24/7), the agents are restarted after three continuous days of uptime.

Important

Agents in stateful pools can still be shut down and discarded after a job completes if there is no grace period, no active provisioning period for standby agents, and no queued jobs matching the agent. Once an agent is discarded, any state is lost.

Grace period enables the most cost effective way of running stateful pools for pipelines with consistent load and does not require the use of standby agent mode to keep agents online and ready to accept jobs.

Standby agent mode

When you create a pool, Standby agent mode is off by default, and there are no standby agents to immediately assign to your pipelines, which might have to wait a few moments, up to 15 minutes, for an agent to be provisioned on demand. For better performance, enable Standby agent mode and configure a standby agent schedule that provides capacity for your workload.

When a standby agent schedule is configured, Managed DevOps Pools periodically compares the count of provisioned agents with the standby agent count specified by the current provisioning scheme, and starts new agents as required to maintain the standby agent count. You can view the current status and count of the agents in your pool using the Agents pane.

Important

The provisioning count in a scheme can't be greater than the Maximum agents configured in Pool settings.

Standby agent mode is configured using the following settings:

  • Off - Standby agent mode is off and agents are provisioned on-demand when jobs are queued.
  • Manual - Configure a manual standby schedule.
  • Automatic - Use an automatic standby schedule based on agent usage history and configurable for cost and performance.

Screenshot of standby agent mode selection.

Manual

Manual mode is best suited for teams that have knowledge of their CI/CD pipelines usage patterns. If you select the manual option, you need to define your pre-provisioning scheme based on your understanding of when agents in the pool are most likely to get used and how many agents are likely to be used, and specify a provisioning count of agents that meet the projected demand.

You can create your own provisioning schedule or choose from one of the predefined schedules, and you can configure the time zone to use for specifying the schedules. The default value for Pre-provisioning TimeZone is (UTC) Coordinated Universal Time.

Manual standby agent configuration can be configured in one of the following three ways.

Each of the pre-provisioning quick starts has the following common settings in addition to the specific settings for that quick start.

  • Pre-provisioning TimeZone allows you to configure the time zone for the times in your pre-provisioning scheme. The default value for Pre-provisioning TimeZone is (UTC) Coordinated Universal Time.
  • Standby agent percentage configures the percentage of standby agents you want for each image. You can enter * to ensure all images are provisioned equally, or you can specify an integer from 0 to 100 to represent a percentage. If you specify a percentage, the total for all images must equal 100. If you have a single image, specify * or 100. Standby agent percentage is configured in the images section when using ARM templates. For more information, see Configure images.

Screenshot of manual standby mode.

Start From scratch

If you choose to start from scratch, you can add a list of provisioning periods to serve as your provisioning scheme. Each provisioning period consists of a start day, end day, time zone, start time, end time, and a count. Provisioning periods can't overlap each other.

Property Description
Multi-day When checked, you can configure both a Start Day and an End Day for your provisioning scheme.
Until next period When checked, the provisioning period runs from the Start Time until the start of the next provisioning period.
Start Day The day that the provisioning period starts.
End Day The day the provisioning period ends. Required if Multi-Day is checked.
Start Time The time the provisioning period starts.
End Time The time the provisioning period ends. Required unless Until next period is checked.
Count The number of standby agents to provision. This number must be greater than zero, and must not be greater than the Maximum agents value configured in Pool settings.

After creating a provisioning period, you can delete or edit the period from the Pre-provisioning scheme list.

The following example configures a manual scheme with 1 agent provisioned on Monday mornings from 12:00 AM to 5:00 AM EST.

Screenshot of manual scaling scheme.

Weekday scheme

If you choose the weekday scheme, you can specify a start time and end time in which the specified number of standby agents will be on standby each weekday.

Property Description
Start Time The time the provisioning period starts.
End Time The time the provisioning period ends.
Provisioning Count The number of standby agents to provision. This number must be greater than zero, and must not be greater than the Maximum agents value configured in Pool settings.

The following example configures four agents to be used during working hours with 0 agents during non-working hours and weekends, using Eastern Standard Time.

Screenshot of weekday scheme.

All Week Scheme

If you choose the all week scheme, you can specify a number of agents you want available 24/7.

Screenshot of all week scheme.

Automatic

If you don't know your usage patterns and want to rely on automatic forecasting based on past data, choose Automatic. You can balance between cost and agent performance using a slider with the following five options. Managed DevOps Pools runs a query over your past three weeks of historical data (if available), organizing queued sessions of the pool into five minute periods, and assigns the specified percentile (to avoid spikes) to each hour.

  • Most cost effective (MostCostEffective) - 10th percentile
  • More cost effective (MoreCostEffective) - 25th percentile
  • Balanced (default) (Balanced) - 50th percentile
  • More performance (MorePerformance) - 75th percentile
  • Best performance (BestPerformance) - 90th percentile

Screenshot of automatic scaling setting.

See also