You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/scaling-your-services.mdx
+37-3Lines changed: 37 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,14 +27,14 @@ services:
27
27
deploy:
28
28
resources:
29
29
reservations:
30
-
cpus: '2'
31
-
memory: '512M'
30
+
cpus: "2"
31
+
memory: "512M"
32
32
```
33
33
34
34
The minimum resources which can be reserved:
35
35
36
36
| Resource | Minimum |
37
-
|----------|---------|
37
+
|-------- | -------|
38
38
| CPUs | 0.5 |
39
39
| Memory | 512M |
40
40
@@ -57,3 +57,37 @@ services:
57
57
deploy:
58
58
replicas: 3
59
59
```
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