|
1 | 1 | --- |
2 | 2 | title: Autoscaling |
3 | | -description: Learn how autoscaling dynamically adjusts app instances based on CPU usage to keep apps responsive under load while optimizing costs. |
| 3 | +description: Learn how autoscaling adjusts app instances based on CPU and memory usage to keep apps stable and cost-efficient under varying workloads. |
4 | 4 | weight: -100 |
5 | 5 | keywords: |
6 | 6 | - "resources" |
7 | 7 | - "CPU" |
8 | 8 | - "autoscaling" |
9 | 9 | - "scaling" |
10 | 10 | --- |
| 11 | +<!-- vale off --> |
| 12 | +Autoscaling is a feature that automatically adjusts how many instances of your application are running, increasing capacity when demand rises, and reducing it when things are quiet. It helps your app stay responsive under heavy load while keeping your infrastructure costs efficient. |
11 | 13 |
|
12 | | -Autoscaling allows your applications to automatically [scale horizontally](/manage-resources/adjust-resources.html#horizontal-scaling) based on resource usage. |
| 14 | +## What is autoscaling? |
13 | 15 |
|
14 | | -This ensures your apps remain responsive under load while helping you optimize costs. |
| 16 | +Autoscaling works through [horizontal scaling](/manage-resources/adjust-resources.html#horizontal-scaling), by adding or removing whole application instances depending on resource usage. If CPU or [memory](#memory-based-autoscaling) utilization stays above a certain threshold for a set time, {{% vendor/name %}} automatically adds more instances. If it stays low, {{% vendor/name %}} removes unneeded ones. You control these thresholds and limits, so scaling always happens safely and predictably. |
15 | 17 |
|
16 | 18 | - **Scope:** Available for applications only |
17 | 19 | - **Product tiers:** Available for all Upsun Flex environments |
18 | 20 | - **Environments:** Configurable per environment - across development, staging, and production |
19 | 21 |
|
| 22 | +{{< note theme="info" title="Know your app first">}} |
| 23 | +Autoscaling is quick to set up: you can [enable it in a few clicks](#enable-autoscaling) from your environment’s **Configure resources** tab. However, it’s important to understand your app’s typical performance before turning it on. |
| 24 | + |
| 25 | +Tools like [Blackfire](https://www.blackfire.io/) can help you identify where your app consumes CPU or memory, so you can set realistic thresholds that reflect your traffic patterns. Blackfire can also help you spot whether autoscaling is likely to benefit your app or if a fixed setup with tuned [vertical resources](/manage-resources/adjust-resources.html#vertical-scaling) like CPU/RAM would serve you better. |
| 26 | +{{< /note >}} |
| 27 | + |
| 28 | +## When to use autoscaling |
| 29 | + |
| 30 | +Autoscaling makes the most sense for workloads with variable or unpredictable traffic. It’s especially valuable when: |
| 31 | + |
| 32 | +- You run time-sensitive or customer-facing applications where latency matters. |
| 33 | +- Your app experiences seasonal or campaign-driven spikes. |
| 34 | +- You want to avoid paying for idle capacity during quieter periods. |
| 35 | + |
| 36 | +### Example: When autoscaling works effectively |
| 37 | +A retail app sees traffic jump fivefold every Friday evening and during holiday campaigns. By enabling autoscaling, the app automatically adds instances when CPU usage rises and scales back overnight, ensuring smooth checkouts without wasted cost. |
| 38 | + |
| 39 | +### Example: When autoscaling might not be needed |
| 40 | +An internal dashboard with predictable, low usage may not benefit from autoscaling. In this case, a fixed number of instances and tuned vertical resources (CPU/RAM) can be more cost-effective and stable. |
| 41 | + |
20 | 42 | {{< note theme="info" title="Scale databases and resources">}} |
21 | 43 |
|
22 | 44 | To vertically scale CPU, RAM, or disk, or horizontally scale applications and workers (manually), see: |
@@ -59,21 +81,30 @@ The tables below outline where autoscaling and manual scaling are supported, so |
59 | 81 | | Trigger | Console | |
60 | 82 | | ------------------------- | ----------- | |
61 | 83 | | Average CPU (min/max) | Available | |
62 | | -| Average Memory (min/max) | Coming | |
| 84 | +| Average Memory (min/max) | Available | |
63 | 85 |
|
64 | | - |
65 | 86 | ## How autoscaling works |
66 | 87 |
|
67 | 88 | ### Thresholds |
68 | 89 |
|
69 | | -Autoscaling continuously monitors the average CPU utilization across your app's running instances. It works by you setting your thresholds, which are specific CPU usage levels that determine when autoscaling should take action. There are two different thresholds that your CPU utilization operates within: A scale-up threshold and a scale-down threshold. |
| 90 | +Autoscaling monitors the average CPU and [memory usage](#memory-based-autoscaling) of your running app instances. |
| 91 | +You define thresholds that determine when new instances are launched or removed. |
| 92 | + |
| 93 | +There are two different thresholds that your CPU and memory utilization operate within: A scale-up threshold and a scale-down threshold. |
70 | 94 |
|
71 | 95 | - **Scale-up threshold**: If your chosen trigger (e.g. CPU usage) stays **above** this level for the time period you've set (the evaluation period), autoscaling will launch additional instances to share the load. |
72 | 96 |
|
73 | 97 | - **Scale-down threshold**: If your chosen trigger stays **below** this level for the time period you've set, autoscaling will remove unneeded instances to save resources and costs. |
74 | 98 |
|
75 | 99 | To prevent unnecessary back-and-forth, autoscaling also uses a cooldown window: a short waiting period before another scaling action can be triggered. This can also be configured or kept to the [default](#default-settings) waiting period before any additional scaling starts. |
76 | 100 |
|
| 101 | +{{< note theme="warning" title="Combined triggers" >}} |
| 102 | + |
| 103 | +If both CPU and memory triggers are enabled, either one can initiate scaling. A global cooldown applies after each scaling event, but in rare cases, combined triggers may interact unexpectedly. For example, CPU scaling up followed by memory scaling down. Adjust thresholds and cooldowns carefully to avoid oscillation. |
| 104 | + |
| 105 | +{{< /note >}} |
| 106 | + |
| 107 | + |
77 | 108 | ### Default settings |
78 | 109 |
|
79 | 110 | Autoscaling continuously monitors the configured **trigger** across your app’s running instances. We will use the **average CPU utilization** trigger as the primary example for the default settings and examples below. |
@@ -103,6 +134,46 @@ Autoscaling continuously monitors the configured **trigger** across your app’s |
103 | 134 |
|
104 | 135 | This cycle ensures your app automatically scales up during high demand and scales down when demand drops, helping balance performance with cost efficiency. |
105 | 136 |
|
| 137 | +## Memory-based autoscaling |
| 138 | + |
| 139 | +Autoscaling primarily relies on CPU utilization as its trigger, however you can also configure memory-based autoscaling, which works in a similar way, but with a few important differences to understand. |
| 140 | + |
| 141 | +### CPU-based triggers |
| 142 | + |
| 143 | +CPU-based autoscaling reacts to sustained changes in average CPU utilization. |
| 144 | + |
| 145 | +- Scale-up threshold: When average CPU usage stays above your defined limit for the evaluation period, instances are added to distribute the load. |
| 146 | +- Scale-down threshold: When CPU usage remains below your lower limit for the evaluation period, instances are removed to save resources. |
| 147 | +- Cooldown window: A delay (default: 5 minutes) before another scaling action can occur. |
| 148 | + |
| 149 | +### Memory-based triggers |
| 150 | + |
| 151 | +Memory-based autoscaling follows the same principle as CPU triggers but measures average memory utilization instead. When your app consistently uses more memory than your upper threshold, {{% vendor/name %}} adds instances; when memory usage remains low, it removes them. |
| 152 | + |
| 153 | +This option is useful for workloads where caching or in-memory data handling determine performance - for example, large data processing apps or services with persistent caching layers. |
| 154 | + |
| 155 | +#### Example |
| 156 | + |
| 157 | +| Condition | Scaling action | |
| 158 | +|------------|----------------| |
| 159 | +| Memory above 80% for 5 minutes | Scale up: Add one instance | |
| 160 | +| Memory below 30% for 5 minutes | Scale down: Remove one instance | |
| 161 | + |
| 162 | +{{< note theme="warning" title="Understand your app’s memory profile" >}} |
| 163 | +High memory usage doesn’t always mean your app needs more instances. Linux systems use available memory for caching and buffering, so 90–100% usage can be normal even under stable conditions. Before using memory-based autoscaling, profile your application’s typical memory behavior to avoid unnecessary scaling and extra cost. |
| 164 | + |
| 165 | +Tools such as [Blackfire](https://www.blackfire.io/) or system-level metrics in your [Application metrics dashboard](/increase-observability/application-metrics.html) can help you understand what “normal” looks like for your app. |
| 166 | +{{< /note >}} |
| 167 | + |
| 168 | +#### Configure memory triggers |
| 169 | +1. Open your project in the Console. |
| 170 | +2. Select your target environment. |
| 171 | +3. Choose **Configure resources**. |
| 172 | +4. Under **Autoscaling**, select **Enable** (if not already enabled). |
| 173 | +5. Choose **Memory usage (min/max)** as your scaling trigger. |
| 174 | +6. Set scale-up and scale-down thresholds, evaluation period, and cooldown window. |
| 175 | +7. Save changes — your app will now automatically scale based on memory utilization. |
| 176 | + |
106 | 177 | ## Guardrails and evaluation |
107 | 178 |
|
108 | 179 | Autoscaling gives you control over the minimum and maximum number of instances your app can run. These guardrails ensure your app never scales up or down too far. Set boundaries to keep scaling safe, predictable, and cost-efficient: |
@@ -234,3 +305,4 @@ Scaling down to zero instances is also **not supported**. Use minimum instance c |
234 | 305 | - [Payment FAQ](/administration/billing/payment-faq.html) |
235 | 306 | - [Monitor billing](/administration/billing/monitor-billing.html) |
236 | 307 | - [Pricing overview](https://www.upsun.com/pricing/) |
| 308 | +<!-- vale on --> |
0 commit comments