Autoscaling Fly Machines (v2)

I’m trying to figure out if Fly is suitable for my indie projects using Phoenix/Elixir. The main thing I need is autoscaling (up and down). Basically:

  • Scale up if there’s sudden a spike in traffic.
  • Scale down to zero if nobody is using my apps.

Scaling to zero seems very straightforward using auto_stop_machines, auto_start_machines and min_machines_running. I’ve tested it and it works well, great job!

However, if I’m understanding correctly, autoscaling up was available in the past (Nomad v1) but it’s not available anymore (Machines v2).

If I want to scale up horizontally, I need to manually use fly scale up. If I need to scale it vertically, I need to manually use fly scale.

So, I need to predict what my traffic is going to be and plan accordingly. If I have an unpredicted spike and I’m not around my computer, then my apps will go down, correct?

If so, two other questions:

  1. What happens when my app reaches its limits and goes down? Do I receive an alert/notification?
  2. I can only use flyctl to scale it up, correct? For example, let’s say it has an unexpected spike and I don’t have my computer with me. I can’t use the dashboard on my phone to scale it up, right?


Hi @wceolin

To answer your questions:

If a machine reaches it’s hard limit as configured in the fly.toml, it won’t accept any more connections, and if there’s no machines that aren’t at the hard limit then the proxy will return an error (typically 502 HTTP error I think). If your machine happens to crash because it’s out of memory then sometimes you’ll receive an email from fly. In either case, the recommendation would be to setup your own monitoring that can alert you to when your app is hitting it’s limits.

You can use either the fly CLI to scale up or the machines API, though typically you’ll only use the CLI. There isn’t currently a way to scale up from the dashboard.

You should look at the max number of machines as the limit for how much you’re willing to spend. Are you willing to spend $100/month or $10,000/month? If your app suddenly gets a lot of traffic are you willing to pay for that extra traffic?

With that in mind, another option to consider is to over-provision your machines for expected spikes. So you could provision 25 machines with autostart/autostop meaning that when your traffic is low most of the machines will be stopped and you won’t be paying for them, and then when you have a spike those extra machines will automatically start up and service the traffic which is when you’d start paying for them until the stop again.

1 Like

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