You can configure scheduled limit changes in App Autoscaler for apps in your TAS for VMs deployment.

Overview of scheduled limit changes

When you create scaling limits for an app, you define the minimum and maximum number of instances that Autoscaler can create for an app. When you configure scheduled limit changes for an app, Autoscaler can change these scaling limits according to a schedule that you define.

VMware recommends that you configure scheduled limit changes when you can reasonably predict how many instances your apps require during any given period of time. The following list describes common use cases for scheduled limit changes:

  • You can pre-emptively scale for an expected period of high traffic by increasing the upper scaling limit to a higher value than what Autoscaler might select based on the configured scaling metrics.

  • You can reduce redundant resource usage during expected periods of low traffic by reducing the lower scaling limit during those periods.

  • You can control resource usage during periods in which users can tolerate the effects of an overloaded app by reducing the upper scaling limit during those periods.

If you want to ensure that Autoscaler creates enough instances of an app to handle the amount of traffic that it receives at any given time, but the amount of traffic that the app receives is less predictable, you can change the scaling factors for the app. Setting a higher scale-up factor can help ensure that Autoscaler scales up quickly enough to sufficiently handle a high amount of traffic. For more information, see Update scaling factors in Using the App Autoscaler CLI.

VMware recommends that you load-test your app to verify that the scheduled limit changes you configured are effective. For more information, see Load-testing your App in Using Autoscaler in production.

Configuring scheduled limit changes through the cf CLI

The procedures in this section describe how to configure scheduled limit changes for Autoscaler through the Cloud Foundry Command-Line Interface (cf CLI).

You can configure scheduled limit changes in the following ways:

For the procedures in this section, you must use the App Autoscaler CLI plug-in. To download and install the App Autoscaler CLI plug-in, see Install the App Autoscaler CLI plug-in in Using the App Autoscaler CLI.

Configure scheduled limit changes using a manifest file

You can configure scheduled limit changes declaratively through a manifest file. This manifest file only configures Autoscaler, and does not interfere with any other existing app manifest files in your TAS for VMs deployment.

To configure scheduled limit changes using a manifest file:

  1. In a terminal window, target the space in which the app you want to scale is deployed by running:

    cf target -o ORG-NAME -s SPACE-NAME
    

    Where:

    • ORG-NAME is the name of the org containing the space in which the app you want to scale is deployed.
    • SPACE-NAME is the name of the space in which the app you want to scale is deployed.
  2. If the space in which the app you want to scale is deployed does not already have a service instance of Autoscaler deployed in it, create an Autoscaler service instance by running:

    cf create-service app-autoscaler PLAN-NAME SERVICE-NAME
    

    Where:

    • PLAN-NAME is the name of the service plan you want to use for the Autoscaler service instance.
    • SERVICE-INSTANCE-NAME is the name you want to give the Autoscaler service instance. For example, autoscaler.
    If there is already an Autoscaler service instance in the space in which the app you want to scale is deployed, skip this step.
  3. Bind the Autoscaler service instance to the app you want to scale by running:

    cf bind-service APP-NAME SERVICE-INSTANCE-NAME
    

    Where:

    • APP-NAME is the name of the app you want to scale.
    • SERVICE-INSTANCE-NAME is the name of the Autoscaler service instance.
  4. To create a manifest file for Autoscaler that configures a scheduled limit change, create a YAML file that includes the following configuration parameters:

    instance_limits:
      min: LOWER-SCALING-LIMIT
      max: UPPER-SCALING-LIMIT
    rules: []
    scheduled_limit_changes:
    - recurrence: RECURRENCE
      executes_at: "TIME"
      instance_limits:
        min: SCHEDULED-LOWER-SCALING-LIMIT
        max: SCHEDULED-UPPER-SCALING-LIMIT
    

    Where:

    • LOWER-SCALING-LIMIT is the minimum number of instances that you configured Autoscaler to create for the app by default.
    • UPPER-SCALING-LIMIT is the maximum number of instances that you configured Autoscaler to create for the app by default.
    • (Optional) RECURRENCE is the calculated value of the bitmasked days of the week on which you want Autoscaler to re-apply the scheduled limit change. For more information, see Calculating a recurrence schedule value.
    • TIME is the time, in UTC timestamp format, at which you want Autoscaler to apply the scheduled limit change. For example, 2032-01-01T20:00:00Z. If the value that you configure for TIME is your local time converted to UTC time, and Daylight Saving Time is observed in your time zone, the UTC offset for your time zone might change during the year.
    • SCHEDULED-LOWER-SCALING-LIMIT is the minimum number of instances you want Autoscaler to create for the app during the scheduled limit change. If the current number of app instances is fewer than this number at the time of the scheduled limit change, Autoscaler scales the number of app instances up to this number.
    • SCHEDULED-UPPER-SCALING-LIMIT is the maximum number of instances you want Autoscaler to create for the app during the scheduled limit change. If the current number of app instances is greater than this number at the time of the scheduled limit change, Autoscaler scales the number of app instances down to this number.
  5. Apply the manifest file you configured in the previous step to the app for which you want to configure scheduled limit changes by running:

    cf configure-autoscaling APP-NAME MANIFEST-FILENAME
    

    Where:

    • APP-NAME is the name of the app.
    • MANIFEST-FILENAME is the filename of the manifest file you created in the previous step.

    For example, running the following applies the autoscaler.yml manifest file to example-app:

    cf configure-autoscaling example-app autoscaler-manifest.yml.
    

    The earlier command returns output similar to the following example:

    Setting autoscaler settings for app example-app for org example-org / space example-space as user
    OK
    

Calculating a recurrence schedule value

When you configure a recurring scheduled limit change for Autoscaler using a manifest file, Autoscaler uses the recurrence value and executes at value to set the date and time of the first occurrence of a scheduled limit change. Autoscaler then uses the time value to set the time of day for all subsequent scheduled limit changes.

Because Autoscaler bitmasks the days of the week in its recurrence schedule, you must calculate the correct value to enter for the recurrence property in your Autoscaler manifest file.

To calculate a recurrence value:

  1. Add together the bitmasked values for each day of the week that you want Autoscaler to apply the scheduled limit change. The following table shows the bitmasked values for each day of the week:
    Day Su Mo Tu We Th Fr Sa
    Value 64 32 16 8 4 2 1
    For example:
    • To apply the scheduled limit change on weekdays, use the following calculation: 32+16+8+4+2=62. In your Autoscaler manifest, the value of recurrence must be 62.
    • To apply the scheduled limit change on weekends, use the following calculation: 64+1=65. In your Autoscaler manifest, the value of recurrence must be 65.
    • To apply the scheduled limit change every day, use the following calculation: 64+32+16+8+4+2+1=127. In your Autoscaler manifest, the value of recurrence must be 127.
    • To apply the scheduled limit change on Monday, Wednesday, and Friday, use the following calculation: 32+8+2=42. In your Autoscaler manifest, the value of recurrence must be 42.

The following example manifest configures Autoscaler to scale the number of app instances down every Friday at 8 PM UTC, then scale them back up every Monday at 4 AM UTC:

---
...
scheduled_limit_changes:
- recurrence: 32
  executes_at: "2032-01-01T20:00:00Z"
  instance_limits:
    min: 1
    max: 3
- recurrence: 2
  executes_at: "2032-01-01T04:00:00Z"
  instance_limits:
    min: 6
    max: 12

Configure scheduled limit changes using CLI commands

To configure scheduled limit changes using CLI commands:

  1. In a terminal window, target the space in which the app you want to scale is deployed by running:

    cf target -o ORG-NAME -s SPACE-NAME
    

    Where:

    • ORG-NAME is the name of the org containing the space in which the app you want to scale is deployed.
    • SPACE-NAME is the name of the space in which the app you want to scale is deployed.
  2. If the space in which the app you want to scale is deployed does not already have a service instance of Autoscaler deployed in it, create an Autoscaler service instance by running:

    cf create-service app-autoscaler PLAN-NAME SERVICE-INSTANCE-NAME
    

    Where:

    • PLAN-NAME is the name of the service plan you want to use for the Autoscaler service instance.
    • SERVICE-INSTANCE-NAME is the name you want to give the Autoscaler service instance. For example, autoscaler.

    If there is already an Autoscaler service instance in the space in which the app you want to scale is deployed, skip this step.

  3. Bind the Autoscaler service instance to the app you want to scale by running:

    cf bind-service APP-NAME SERVICE-INSTANCE-NAME
    

    Where:

    • APP-NAME is the name of the app you want to scale.
    • SERVICE-INSTANCE-NAME is the name of the Autoscaler service instance.
  4. Configure upper and lower scaling limits for the app by running:

    cf update-autoscaling-limits APP-NAME LOWER-SCALING-LIMIT UPPER-SCALING-LIMIT
    

    Where:

    • APP-NAME is the name of the app.
    • LOWER-SCALING-LIMIT is the minimum number of instances you want Autoscaler to create for the app.
    • UPPER-SCALING-LIMIT is the maximum number of instances you want Autoscaler to create for the app.
  5. Allow Autoscaler to begin making scaling decisions for the app by running:

    cf enable-autoscaling APP-NAME
    

    Where APP-NAME is the name of the app.

  6. Create a scheduled limit change by running:

    cf create-autoscaling-slc APP-NAME TIME LOWER-SCALING-LIMIT UPPER-SCALING-LIMIT --recurrence DAY-1,DAY-2,DAY-3
    

    Where:

    • APP-NAME is the name of the app.
    • TIME is the time, in UTC timestamp format, at which you want Autoscaler to apply the scheduled limit change. For example, 2032-01-01T20:00:00Z. If the value that you configure for TIME is your local time converted to UTC time, and Daylight Saving Time is observed in your time zone, the UTC offset for your time zone might change during the year.
    • LOWER-SCALING-LIMIT is the minimum number of instances you want Autoscaler to create for the app during the scheduled limit change. If the current number of app instances is fewer than this number at the time of the scheduled limit change, Autoscaler scales the number of app instances up to this number.
    • UPPER-SCALING-LIMIT is the maximum number of instances you want Autoscaler to create for the app during the scheduled limit change. If the current number of app instances is greater than this number at the time of the scheduled limit change, Autoscaler scales the number of app instances down to this number.
    • (Optional) Include the --recurrence parameter to specify the days of the week on which you want Autoscaler to re-apply the scheduled limit change, where DAY-1, DAY-2, DAY-3, and so on are the days you want to specify. Valid values are Mo, Tu, We, Th, Fr, Sa, or Su. For example, if you want Autoscaler to re-apply the scheduled limit change on Monday, Wednesday, Friday, and Saturday, include --recurrence Mo,We,Fr,Sa in the command.

Configuring scheduled limit changes through Apps Manager

To configure scheduled limit changes through Apps Manager, see Create or edit scheduled limit changes in Scaling an App Using App Autoscaler.

Reviewing autoscaling events for scheduled limit changes

When Autoscaler applies a scheduled limit change, it records an autoscaling event. If the current number of app instances is under the lower scaling limit of the scheduled limit change, Autoscaler scales the number of app instances up to the lower scaling limit and records a separate autoscaling event.

You can review the autoscaling events that Autoscaler records for scheduled limit changes in the following ways:

Review autoscaling events for scheduled limit changes through the cf CLI

To review the autoscaling events that Autoscaler records for scheduled limit changes through the cf CLI:

  1. In a terminal window, run:

    cf autoscaling-events APP-NAME
    

    Where APP-NAME is the name of the app for which you want to review autoscaling events.

    If Autoscaler has recorded autoscaling events for scheduled limit changes, the above command returns output that contains autoscaling events similar to the following example:

    Time                   Description
    2022-05-26T21:32:17Z   Scaling from 10 to 20 instances: app below minimum instance limit
    2022-05-26T21:31:50Z   Rule Applied: Scaling Limits set to 20 to 100 instances
    

Review autoscaling events for scheduled limit changes through Apps Manager

To review the autoscaling events that Autoscaler records for scheduled limit changes through Apps Manager:

  1. Log in to Apps Manager. For more information, see Logging in to Apps Manager.

  2. Select the org that contains the space in which the app you want to scale is deployed.

  3. Select the space in which the app you want to scale is deployed.

  4. Under Processes and Instances, click Autoscaling Activated.

  5. Under Event History, click View More. A list of autoscaling events appears. If Autoscaler has recorded autoscaling events for scheduled limit changes, the list of autoscaling events includes events similar to the following example:

    Scaling from 10 to 20 instances: app below minimum instance limit
    Rule Applied: Scaling Limits set to 20 to 100 instances
    
check-circle-line exclamation-circle-line close-line
Scroll to top icon