Scaling an Application Using App Autoscaler

This topic describes how Pivotal Cloud Foundry (PCF) users with the Space Developer role can set up and configure the App Autoscaler service in the Apps Manager UI to automatically scale apps based on rules that they set.

You can use the App Autoscaler command-line interface (CLI) plugin to configure App Autoscaler rules from the command line.

NOTE: Space Managers, Space Auditors, and all Org roles do not have permission to use App Autoscaler. For help managing user roles, see Managing User Accounts and Permissions Using the Apps Manager.

App Autoscaler Overview

App Autoscaler is a marketplace service that helps control the cost of running apps while maintaining app performance.

To balance app performance and cost, Space Developers can use App Autoscaler to do the following:

  • Configure rules that adjust instance counts based on metrics thresholds, such as CPU Usage
  • Modify the maximum and minimum number of instances for an app, either manually or following a schedule

Breaking Change: App Autoscaler relies on API endpoints from Loggregator’s Log Cache. If you disable Log Cache, App Autoscaler will fail. For more information about Log Cache, see Loggregator Introduces Log Cache.

Set Up App Autoscaler

To use App Autoscaler, you must create an instance of the App Autoscaler service and bind it to any app you want to autoscale. You can do this using either the Apps Manager or from the Cloud Foundry Command Line Interface (cf CLI):

Follow these steps to enable App Autoscaler for the app:

  1. In Apps Manager, select an app from the space in which you created the App Autoscaler service.

  2. Under Processes and Instances, enable Autoscaling. In the 'Processes and Instances' section of the 'Overview' pane, find 'Autoscaling' two rows below the title of each process.

  3. Click Manage Autoscaling to configure instance limits, scaling rules, and scheduled limit changes for the app.

    Manage autoscaling

Manual Scaling Overrides Autoscaler

If you manually scale an app bound to an App Autoscaler service instance, the App Autoscaler instance automatically unbinds from that app, and the app scales to the manual setting.

Configure Autoscaling for an App

App Autoscaler keeps instance counts within an allowable range defined by minimum and maximum values, or instance limits.

Follow the procedures in the sections below to set any of the following:

Instance Limits

Follow these steps to manually modify instance limits:

Note: You can also schedule changes to your instance limits for a specific date and time.

  1. In Apps Manager, navigate to the Overview page for your app and click Manage Autoscaling under Processes and Instances.

  2. In the INSTANCE LIMITS section, set values for Minimum and Maximum.

    Instance limits


Scaling Rules

To keep your apps available without wasting resources, App Autoscaler increments or decrements instance counts based on how current metrics compare with configurable minimum and maximum thresholds.

How App Autoscaler Determines When to Scale

App Autoscaler scales apps as follows:

  • Increment by one instance when any metric exceeds the maximum threshold specified
  • Decrement by one instance only when all metrics fall below the minimum threshold specified

Scaling Rule Metrics

The table below lists the metrics that you can base App Autoscaler rules on:

Metric Description
CPU Utilization Average CPU percentage for all instances of the app.
Container Memory Utilization Average memory percentage for all instances of the app.
HTTP Throughput Total HTTP requests per second (divided by the total number of app instances).
HTTP Latency Average latency of apps response to HTTP requests. This does not include Gorouter processing time or other network latency.
Average is calculated on the middle 99% or middle 95% of all HTTP requests.
RabbitMQ Depth The queue length of the specified queue.
Custom Users can configure their apps to emit custom metrics out of the Loggregator Firehose. For steps on how to set up your apps to emit custom metrics, refer to the Metrics Forwarder Documentation.
Compare One custom metric divided by another. When you add a rule, the Metric field is the dividend and the Comparison Metric field is the divisor.

Add a Scaling Rule

  1. In the Manage Autoscaling pane, click EDIT next to SCALING RULES. The Edit Scaling Rules pane appears.

  2. Click ADD RULE.

  3. In the Select type dropdown, select the metric for the new scaling rule.

    Scaling rules

  4. Set the minimum and maximum thresholds for the metric using the table in the Scaling Rule Metrics section above as a guide.

  5. Select or fill in any other fields that appear under the threshold fields:

    • If you are adding an HTTP Latency rule, configure Percent of traffic to apply.
    • If you are adding a RabbitMQ depth rule, provide the name of the queue to measure.
    • If you are adding a Custom rule, enter your custom Metric.
    • If you are adding a Compare rule, enter values in the Metric and Comparison Metric fields.
  6. Click SAVE.

Delete a Scaling Rule

  1. Click the × icon next to the rule you want to delete.

  2. Click SAVE.

Scheduled Limit Changes

Because app demand often follows a weekly, daily, or hourly schedule, you can schedule App Autoscaler to change the allowable instance range to track expected surges or quiet periods.

Create or Modify a Scheduled Limit Change

  1. Click EDIT next to SCHEDULED LIMITS.

  2. Click ADD NEW to add a new scheduled limit or select an existing entry to modify by clicking EDIT next to the entry.

  3. Edit the following values:

    • Date and Time (local): Set the date and time of the change.
    • Repeat (Optional): Set the day of the week for which you want to repeat the change.
    • Min and Max: Set the allowable range within which App Autoscaler can change the instance count for an app.

      Scheduled changes

  4. Click SAVE.

To delete an existing entry, click the x icon next to the entry you want to delete.

Example: Scale Down for the Weekend

To schedule an app to scale down for a weekend, you can enter two rules as follows:

  1. Scale down to a single instance on Friday evening:
    • Date and Time (local): Dec, 2, 2018 and 7:00 PM
    • Repeat (Optional): Fr
    • Min and Max: 1 and 1
  2. Increase instances to between 3 and 5 on Monday morning:
    • Date and Time (local): Dec, 5, 2018 and 7:00 AM
    • Repeat (Optional): M
    • Min and Max: 3 and 5

App Autoscaler Events and Notifications

App Autoscaler logs all autoscaling events.

View Event History

To view all autoscaling events in the past 24 hours, click VIEW MORE in the Event History section of the Manage Autoscaling pane.

Event history

Manage App Autoscaler Notifications

Autoscaler emails or texts its event notifications to all space users by default.

Follow these steps to subscribe or unsubscribe from autoscaling event notifications:

  1. Navigate to the Manage Notifications page of PCF.

    Note: If installed, Notifications Management should be available at https://notifications-ui.YOUR-SYSTEM-DOMAIN/preferences.

  2. Choose which notifications you want to receive from App Autoscaler:


Create a pull request or raise an issue on the source for this page in GitHub