How to have minimum one machine running in multiple regions.

Hi Guys,

I am totally new here, so need to learn a bit more about the platform.
I have deployed an app in multiple regions with setting min_machines_running=1.
In one one of the region all replicas get stopped and then we get a cold start.
I want at least one replica running in each region.

Please let me know if it’s possible?

Thanks

1 Like

Hello.

[http_service]

auto_stop_machines = true
auto_start_machines = true
min_machines_running = 1

If you put that in your fly.toml it should work. If not, probably there’s something atypical happening in that specific region

Hi @fly-learner

The min_machines_running setting applies only to your primary region (primary_region in your fly.toml). That’s why all the Machines get stopped in the other region.

You can configure settings on individual Machines, but I’ll have to check into whether that would work in your scenario.

@andie

So, in that case, the replicas will scale to zero by default on all non-primary regions?

@merciof That’s correct.

1 Like

@fly-learner

You could try the following solution, although it adds an extra step post-deploy.

Choose a Machine in the second region to be your always-on Machine. Use fly status to get the Machine ID.

Run the following command to turn off autostop for that Machine only:

fly m update <machine id> --autostop=false

Say yes to config changes:

Configuration changes to be applied to machine: <machine id> (my-app-name)

  	... // 15 identical lines
  	      "protocol": "tcp",
  	      "internal_port": 8080,
- 	      "autostop": true,
+ 	      "autostop": false,
  	      "autostart": true,
  	      "min_machines_running": 1,
  	... // 27 identical lines

? Apply changes? Yes
Updating machine <machine id>
No health checks found
Machine <machine id> updated successfully!
==> Monitoring health checks
No health checks found
...

Warning: the configuration of all Machines is rewritten by fly.toml when you run fly deploy, so you would have to repeat the above step after every deploy. :frowning:

I also suggest testing this out yourself before depending on it to work, since I only tested it briefly on a hello world app.

Thus, maybe another option is to config fly.tom like:

[http_service]

auto_stop_machines = false
auto_start_machines = false

so, he could provision and keep running at least one instance on primary and non-primary regions without cold starts.

Thanks for the ideas guys.

For now, I have set auto_stop_machines = false and it solves two issues. 1. Machines are running in all regions. 2. There are no cold starts.

Thanks so much!

P.S. it would be very helpful if we could specify multiple regions in the fly.toml and all of those regions are treated equally (as main).

5 Likes

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