Autoscaling application servers in the public cloud is a popular design choice to provide elastic, on-demand scale for the applications while keeping resource costs in check.

Avi Load Balancer provides autoscaling capability based on metrics such as application load, connections, and so on. The scheduled scaling feature complements the autoscaling capabilities to provide a deterministic capacity during a specified period.

Use Case

Scheduled autoscaling allows you to create a policy for a duration, for example, two months, during which your application capacity can be maintained at a specified state, overriding the metrics-based autoscaling.

The feature provides deterministic capacity at these periods so that the application servers are already provisioned and ready for traffic, rather than waiting for metrics-based autoscaling to kick in. This reduces the lead time for application capacity to be available.

Example

An e-commerce provider uses autoscaling policies already to scale up/ down application servers based on incoming traffic (connections per second).

During the holiday shopping season between November through January, the company sees high capacity from afternoon to midnight.

By creating a scheduled autoscaling policy, the company can keep the application capacity at a high value, thus ensuring their application response times are optimum and there is no delay in servicing the added load.

Configuration

Scheduled autoscaling is configured within the existing Server AutoScale Policy, and attached to pool.

The scheduled_scalings configuration has the following sub-parameters:

Parameter

Values

Notes

enable

True / False

Configure this to True to enable scheduled scaling.

desired_capacity

Value up to 1000

Desired number of servers during the scheduled time interval.This could result in scale in or scale out depending on the value entered.

cron_expression

Cron-like expression must be within the start_date and end_date. Supports a fixed integer for minutes and hours.

A cron-like expression at which time the policy is activated for autoscaling_duration hours.

start_date

Date and Time in ISO8601 format.

Date and Time in ISO8601 format.

end_date

Date and Time in ISO8601 format.

End date and time for scheduled autoscaling.

autoscaling_duration

Integer, hours

The duration in hours after cron criteria is met, for which the desired capacity will be maintained.

schedule_max_step

Integer

The number of servers to simultaneously scale. Helps in faster provisioning. The autoscale policy’s scaleout_cooldown parameter is used as cooldown duration between successive scale-out events.

Example Configuration

In the below configuration:

  • The policy is active between 1st October 2021 and 1st February 2022 (based on start_date and end_date).

  • The scheduled scaling must happen every day at 9:10 AM (based on cron_expression).

  • The capacity must be maintained at 50 servers (desired_capacity).

  • The ramp-up must happen in steps of 5 (schedule_max_step).

  • The ramp-up must be maintained for 2 hours (autoscaling_duration).

configure serverautoscalepolicy asp-example 

scheduled_scalings autoscaling_duration 2 

index 1 #index assignment should happen after at least on other field 

enable  #no enable if we want to disable 

desired_capacity 50  

schedule_max_step 5  

start_date 20211001T000000Z #timezone should be UTC 

end_date 20220201T000000Z  

cron_expression '10 9 * * *'  

save (save scheduled_scalings) 

save (save auto scale policy) 
+-------------------------------------+------------------------------------------------+ 

| Field                               | Value                                 | 

+-------------------------------------+-----------------------------------------------+ 

| uuid                                | serverautoscalepolicy-69ce3c2d-b401-4b9a-a834-08fbec8921d9                   | 

| name                                | asp-example                                                                                                           | 

| intelligent_autoscale               | False                                                                                                                 | 

| intelligent_scaleout_margin         | 20                                                                                                                    | 

| intelligent_scalein_margin          | 40                                                                                                                    | 

| max_scaleout_adjustment_step        | 1                                                                                                                     | 

| max_scalein_adjustment_step         | 1                                                                                                                     | 

| scaleout_cooldown                   | 300 sec                                                                                                               | 

| scalein_cooldown                    | 300 sec                                                                                                               | 

| use_predicted_load                  | False                                                                                                                 | 

| delay_for_server_garbage_collection | 0                                                                                                                     | 

| scheduled_scalings[1]               |                                                                                                                       | 

|           enable                    | True                                                                                                                  | 

|           desired_capacity          | 50                                                                                                                    | 

|           cron_expression           | 10 9 * * *                                                                                                           | 

|           start_date                | 20211001T000000Z                                                                                                      | 

|           end_date                  | 20220201T000000Z                                                                                                      | 

|           autoscaling_duration      | 2 hours                                                                                                               | 

|           schedule_max_step         | 5                                                                                                                     | 

| tenant_ref                          | admin                                                                                                                 | 

+-------------------------------------+----------------------------------------------+

Considerations

  • Only one scheduled_scaling configuration is supported for each autoscale policy.

  • If scheduled_scaling is disabled, the other fields such as max_size, min_size, max_scaleout_adjustement_step, max_scalein_adjustment_step, desired_capacity, and schedule_max_step will start to control the pool server size.