Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
185 lines (118 sloc) 8.13 KB
---
title: Scaling an Application Using App Autoscaler
owner: PCF Autoscaler
---
This topic describes how to configure App Autoscaler in the Apps Manager UI to automatically scale applications based on rules that you set.
You can use the [App Autoscaler command-line interface (CLI)](./using-autoscaler-cli.html) plugin to configure App Autoscaler rules from the command line.)
## <a id="overview"></a>Overview
App Autoscaler is a marketplace service that ensures app performance and helps control the cost of running apps.
To balance app performance and cost, Space Developers and Space Managers 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
<p class="note"><strong>Note</strong>: To avoid conflict, if you manually scale an app bound to the App Autoscaler service, then App Autoscaler automatically disables the binding for that app.
</p>
## <a id="setup"></a>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).
<p class="note"><strong>Note</strong>: App Autoscaler has one standard service plan that enables the App Autoscaler to check metrics every 5 seconds on a 30 second window of data. When an autoscaling event occurs, the App Autoscaler allows a 30-second warm-up time before any further scaling events.</p>
* **Apps Manager**:
1. [Create an instance of the service](../../marketplace/use-console.html).
1. [Bind the service to an app](../../marketplace/use-console.html#bind-instance).
* **cf CLI**:
1. [Create an instance of the service](../../devguide/services/managing-services.html#marketplace).
1. [Bind the service to an app](../../devguide/services/managing-services.html#bind).
## <a id="config"></a>Configure Autoscaling for an App
App Autoscaler keeps instance counts within an allowable range defined by minimum and maximum values, or _instance limits_.
Follow these steps to configure the instance limits and set rules for when App Autoscaler scales your app.
1. In Pivotal Web Services (PWS), select an app from the space in which you created the App Autoscaler service and click **Services**.
1. Select the App Autoscaler service from the list of services, and then click **Manage**.
<p class='note'><strong>Note</strong>: You must specifically have the role of Space Developer to access the <strong>Manage</strong> link for the app autoscaling service.
Space Managers, Space Auditors, and all Org roles do not have the permission to make changes to App Autoscaling.
For help managing user roles, see <a href="../../console/console-roles.html">Managing User Accounts and Permissions Using the Apps Manager</a>.</p>
1. Follow the procedures in the sections below to set any of the following:
* [Instance Limits](#limits)
* [Scaling Rules](#metric)
* [Scheduled Limit Changes](#schedule)
![UI](full-autoscaler.png)
### <a id="limits"></a>Instance Limits
Follow these steps to manually modify instance limits:
<p class="note"><strong>Note</strong>: You can also <a href="#schedule">schedule</a> changes to your instance limits for a specific date and time.</p>
1. Click the edit icon next to **Instance Limits**.
1. Enter values for **Minimum** and **Maximum**.
1. Click **Save**.
![Limits](instance-limits.png)
### <a id="metric"></a>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 **High** and **Low** thresholds.
#### How App Autoscaler Determines When to Scale
App Autoscaler scales apps as follows:
* Increment by one instance when any metric exceeds the **High** threshold specified
* Decrement by one instance only when all metrics fall below the **Low** threshold specified
#### Scaling Rule Metrics
The table below lists the metrics that you can base App Autoscaler rules on:
<table id='scaling-rule-metrics' border="1" class="nice" >
<tr>
<th>Metric</th>
<th>Description</th>
</tr><tr>
<td>CPU Utilization</td>
<td>Average CPU percentage for all instances of the app.</td>
</tr><tr>
<td>Memory Utilization</td>
<td>Average Memory percentage for all instances of the app.</td>
</tr><tr>
<td>HTTP Throughput</td>
<td>Total HTTP Requests per second (divided by total app instances).</td>
</tr><tr>
<td>HTTP Latency</td>
<td>Average Latency of applications response to HTTP requests. This does not include Gorouter processing time or other network latency.<br>
Average is calculated on the middle 99% or middle 95% of all HTTP requests.</td>
</tr><tr>
<td>RabbitMQ Depth</td>
<td>The queue length of the specified queue.</td>
</tr>
</table>
#### Add a Scaling Rule
1. Click the **edit** icon next to **Scaling Rules**. The **Edit Scaling Rules** pane appears.
1. Click the **+ add rule** icon.
1. In the **Select a Metric** dropdown, select the metric for the new scaling rule to threshold.
1. Click the slider next to the **Select a Metric** dropdown to enable the new rule.
<p class="note"><strong>Note</strong>: New rules are disabled by default. The ability to enable and disable individual rules will be deprecated in a future release.</p>
1. Set the **Low** and **High** thresholds for the metric using the [table above](#scaling-rule-metrics) as a guide.
![Scaling Rules](rules.png)
1. Select or fill in any other fields that appear under the threshold fields. **HTTP Latency** rules need the middle percentage of traffic to apply to, and **RabbitMQ Depth** rules need the name of the queue to measure.
1. Click **Save**.
#### Delete a Scaling Rule
1. Click the **× delete** icon next to the **Select a Metric** dropdown.
1. Click **Save**.
### <a id="schedule"></a>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 the clock icon next to **Scheduled Limit Changes**.
1. Click **+ ADD NEW** to add a new scheduled limit change or choose an existing entry to modify by clicking the edit icon next to an existing entry.
* To delete an existing entry, click the delete icon **X** next to an existing entry.
1. Edit the following values:
![Scheduled limit changes](scheduled.png)
* Date: **Month**, **Day**, **Year** and **Time**: 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.
1. Click **SAVE**.
#### 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:
* **Month**, **Day**, **Year** and **Time**: `Dec`, `2`, `2016`, and `7:00 PM`
* **Repeats**: `Fr`
* **Min** and **Max**: `1` and `1`
2. Increase instances to between 3 and 5 on Monday morning:
* **Month**, **Day**, **Year** and **Time**: `Dec`, `5`, `2016`, and `7:00 AM`
* **Repeats**: `M`
* **Min** and **Max**: `3` and `5`
## <a id="notifs"></a>App Autoscaler Event History and Notifications
App Autoscaler logs all autoscaling events including scaling decisions and binding auto-disable events.
### View Event History
To view all autoscaling events in the past 24 hours, click the **view more** icon in the Event History section of the Autoscaler UI.
![Scaling Event History](event_history.png)
### Manage App Autoscaler Notifications
App Autoscaler emails 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](https://notifications-ui.run.pivotal.io/preferences) page of PWS.
1. Choose which notifications you want to receive from App Autoscaler:
![Notifications](manage-notifications.png)