Scaling based on CPU

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"

Im not sure but have you try the soft limit ?

It works well in my scenario i just create 8 machine and set soft_limit to 20 now each 20 concurrent user the next machine will start , stopped machine pretty cheap tho …

my calculations were simple 20 = database pooling

right now i can handle sudden burst request in the morning and afternoon

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.