Good evening everyone, hope you’re all doing well.
I’m running an application on two shared-2x machines, and they handle about 95% of the traffic just fine. To be honest, most of the time they’re overkill, but we keep them that way “just in case”.
Context:
At certain times of the day we get a burst of webhooks from some clients (expected, but without a predictable schedule). This usually happens late at night when no one on the team is watching, and the application’s performance degrades significantly.
Our first idea was to scale up the machines only during the night, but we don’t want to waste resources.
Looking at Grafana, I’ve noticed that the machine starts getting CPU throttled, and from there the performance becomes heavily degraded. We have an alert for this, and when it fires I wake up, check manually whether throttling is the issue, and scale the machine if needed.
What I’ve tried so far:
When the alert fires, I check whether any machine is stopped and send a signal to start all of them:
machine_ids=$(flyctl machines list --config ./fly.prod.toml --json | jq -r ‘..id’)
for id in $machine_ids; do
flyctl machines start “$id” --config ./fly.prod.toml
done
But as mentioned, the issue isn’t stopped machines… it’s the CPU throttling.**
What I’d like to do:
I want to know if there’s a way to detect throttled machines using the flyctl machines list command. When an alert fires, the script could automatically check whether any machine is being throttled and trigger a scale-up to shared-4x if necessary.
Is there a way to do this filter?
Forgot to mention:
All our traffic goes through another Nginx application acting as a reverse proxy via Flycast. So I could create a separate application dedicated to processing the webhook endpoints and reduce the chance of degrading performance for other users. However, this also feels like an overkill solution for now that it is a pontual burst for a couple of hours, and it could introduce new issues (forgetting to deploy a feature to all environments, making rollbacks harder, etc.).
Thank you for your help.
