Skip to content

Commit cd044cc

Browse files
committed
Update
1 parent f78cd5e commit cd044cc

1 file changed

Lines changed: 35 additions & 8 deletions

File tree

deploy/configuration-as-code/services/autoscaling.mdx

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,36 @@ For high availability, set `minInstances` to at least 3. See [High Availability
4141

4242
When either CPU or memory usage exceeds your configured threshold, Porter automatically adds replicas. When usage drops, replicas are removed (down to your minimum).
4343

44-
For example, with an 80% CPU threshold:
45-
- If average CPU across pods exceeds 80%, new replicas are added
46-
- If average CPU drops below 80%, excess replicas are removed
44+
### Example: Autoscaling in Action
45+
46+
Consider an API service with this configuration:
47+
48+
```yaml
49+
autoscaling:
50+
enabled: true
51+
minInstances: 2
52+
maxInstances: 10
53+
cpuThresholdPercent: 60
54+
memoryThresholdPercent: 80
55+
```
56+
57+
Here's how the autoscaler responds to changing load:
58+
59+
| Time | Avg CPU | Avg Memory | Replicas | What Happens |
60+
|------|---------|------------|----------|--------------|
61+
| t=0 | 30% | 40% | 2 | Baseline: both metrics below thresholds |
62+
| t=1 | 75% | 50% | 4 | CPU (75%) exceeds 60% threshold → scale up |
63+
| t=2 | 90% | 60% | 6 | CPU still high → continue scaling up |
64+
| t=3 | 55% | 85% | 8 | CPU stabilized, but memory (85%) exceeds 80% → scale up |
65+
| t=4 | 45% | 70% | 8 | Both metrics below thresholds → no change (cooldown period) |
66+
| t=5 | 40% | 50% | 5 | Sustained low usage → scale down |
67+
| t=6 | 35% | 45% | 2 | Continue scaling down to minimum |
68+
69+
Key behaviors:
70+
- **Either metric triggers scaling**: If CPU *or* memory exceeds its threshold, replicas are added
71+
- **Both must be low to scale down**: Replicas are only removed when both CPU and memory are below their thresholds
72+
- **Respects bounds**: Replicas never drop below `minInstances` (2) or exceed `maxInstances` (10)
73+
- **Gradual changes**: The autoscaler adjusts incrementally, not all at once, to avoid oscillation
4774

4875
## Custom Metrics Autoscaling (Prometheus)
4976

@@ -78,11 +105,15 @@ Custom metrics autoscaling requires Prometheus to be accessible in your cluster.
78105

79106
Scale Temporal workflow workers based on task queue depth. Porter monitors your Temporal task queues and automatically adjusts worker count.
80107

108+
<Info>
109+
Temporal autoscaling requires a Temporal integration to be configured. See [Temporal Autoscaling](/configure/temporal-autoscaling) for setup details.
110+
</Info>
111+
81112
| Field | Type | Description |
82113
|-------|------|-------------|
83114
| `temporalAutoscaling.temporalIntegrationId` | string | UUID of the Temporal integration |
84115
| `temporalAutoscaling.taskQueue` | string | Name of the Temporal task queue to monitor |
85-
| `temporalAutoscaling.targetQueueSize` | integer | Target number of tasks in queue per replica |
116+
| `temporalAutoscaling.targetQueueSize` | integer | How many queued tasks each replica should handle (e.g., set to 10 with 100 tasks queued → 10 replicas) |
86117

87118
```yaml
88119
services:
@@ -98,10 +129,6 @@ services:
98129
targetQueueSize: 10
99130
```
100131

101-
<Info>
102-
Temporal autoscaling requires a Temporal integration to be configured. See [Temporal Autoscaling](/configure/temporal-autoscaling) for setup details.
103-
</Info>
104-
105132
## Related Documentation
106133

107134
- [Autoscaling Overview](/configure/autoscaling) - UI-based configuration and concepts

0 commit comments

Comments
 (0)