Skip to content

Commit bf4c93d

Browse files
committed
Add section about autoscaling
1 parent 1c96337 commit bf4c93d

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

docs/tutorials/scaling-your-services.mdx

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ services:
2727
deploy:
2828
resources:
2929
reservations:
30-
cpus: '2'
31-
memory: '512M'
30+
cpus: "2"
31+
memory: "512M"
3232
```
3333
3434
The minimum resources which can be reserved:
3535
3636
| Resource | Minimum |
37-
|----------|---------|
37+
| -------- | ------- |
3838
| CPUs | 0.5 |
3939
| Memory | 512M |
4040
@@ -57,3 +57,37 @@ services:
5757
deploy:
5858
replicas: 3
5959
```
60+
61+
## Autoscaling Your Services
62+
63+
Autoscaling allows your services to automatically adjust the number of replicas based on CPU usage — helping you scale up during traffic spikes and scale down during quieter periods.
64+
65+
> **Note:** Autoscaling is only available to **Pro** tier users.
66+
67+
### Enabling Autoscaling
68+
69+
To enable autoscaling for a service, add the `x-defang-autoscaling: true` field under the service definition in your `compose.yaml` file.
70+
71+
Example:
72+
73+
```yaml
74+
services:
75+
web:
76+
image: myorg/web:latest
77+
ports:
78+
- 80:80
79+
x-defang-autoscaling: true
80+
```
81+
82+
Once deployed, your services' CPU usage is monitored for how much load it is handling, sustained high loads will result in more replicas being started.
83+
84+
Requirements
85+
86+
- You must be on the Pro plan to use autoscaling.
87+
- The service must be stateless or able to run in multiple instances.
88+
- Only CPU metrics are used for scaling decisions.
89+
90+
Best Practices
91+
92+
- Design your services to be horizontally scalable.
93+
- Use shared or external storage if your service writes data.

0 commit comments

Comments
 (0)