Can't seem to set regions for my multi-process app

Hi there,

I’m using the v2 Machines framework, and the dockerfile-generator gem (which works really well by the way!)

It seems to recommend running the app server and Sidekiq for rails in two separate processes, generating the following in my fly.toml

[processes]
  app = "./bin/rails server"
  sidekiq = "bundle exec sidekiq"

I can scale that with:

fly scale count app=2 sidekiq=1

So far so good! But I want the app to run across ams and syd, with Sidekiq just running in syd (writeable region). So I do:

fly regions set syd ams --group app
Region Pool:
ams
syd
Backup Region:

and then

› fly regions set syd -a eme-prod --group sidekiq
Region Pool:
syd
Backup Region:

But now when I try to list the regions, I’m not getting ams back at all. And my new machines aren’t booting there no matter what I do :sob: What am I doing wrong?

› fly regions list
Regions [app]: syd
Regions [sidekiq]: syd

Thanks in advance!

@nikz

Hi @nikz

The only fly regions command that works for V2 apps is fly regions list.

For v2, you add a region just by creating or cloning a machine there. For the scenario you describe, if you only want 2 total machines in your app process, with one in syd and one in ams, then you would specify the regions when you use the fly scale count command:

fly scale count app=2 --region syd,ams

For the sidekiq process, do the same:

fly scale count sidekiq=1 --region syd

Just wanted to add that the primary_region setting in your fly.toml will be the region used whenever you create a new Machine without specifying another region.

Was testing this and it might not be the case. :slight_smile: Looks like fly scale just creates Machines in existing regions if you don’t specify.

@andie thank you for your help! That’s perfect.

It does seem to want to place 2 instances in syd rather than spread them evenly across regions - I wonder if this is due to fly recommending 2 machines minimum per region?

It’s OK though, I can wait for it to scale the machines and then manually delete the ones I don’t want :smiley:

I wonder if you scale down to zero first for the app process? When I test this from zero it seems to work (i.e. it puts one machine in each region).

Thanks, I’ll give that a go!

1 Like

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