Got a autoscaler to scale my app. It communicates with my app and can change the scale, but I didn’t figure how it could scale based on the CPU load. Ideally I’d like to scale
- minimum 3
- maximum 8
- autoscale up if CPU load is ~66%
In general I feel like the docs are not great at giving different common scaling strategies, e.g. ram, cpu, response latency, connections etc.
Here is my attempt, but it does not seem to work
app = "redacted-app-autoscaler"
primary_region = "fra"
[build]
image = "flyio/fly-autoscaler:0.3"
[env]
FAS_APP_NAME = "redacted-app"
FAS_ORG = "redacted-org"
FAS_PROMETHEUS_ADDRESS = "https://api.fly.io/prometheus/redacted-org"
FAS_PROMETHEUS_METRIC_NAME = "avg_cpu"
FAS_PROMETHEUS_QUERY = "clamp_min((sum(rate(fly_instance_cpu{app='$APP_NAME',mode!~'idle|iowait'}[1m])) / sum(fly_instance_cpu_baseline{app='$APP_NAME'})) or on() vector(0), 0)"
FAS_CREATED_MACHINE_COUNT = "max(3, min(5, ceil(avg_cpu / 66)))"
[metrics]
port = 9090
path = "/metrics"