How can I do this? How do I prevent instances of the same app from being started in the same region? I am less concerned about tying each instance to a particular region and more with ensuring two instances of a given app don’t share a region…
When you add multiple regions, we spread instances out as much as possible. If you add, say, 5 regions and then run 4 instances, you should always get one per region on a deploy.
You can get really tight control over regions by adding volumes, if you need to. That would prevent a second instance from ever running in the same region.
Excellent! I’ll make sure I have more regions added than running instances.
I’m so pleased that everything is working out and I found my new app hosting platform!
Hey, has there been any movement on either session or IP affinity since this post? I’m considering some changes to one of my apps and some kind of request affinity would really help. I often run more app instances than there are regions (often 25 or 30 containers) so regional affinity wouldn’t work for me.
No worries if no work has been done here yet! It’s useful to know either way so I can change my approach as necessary.
We haven’t done anything here yet! You can likely do this yourself with two apps:
- Haproxy or nginx with session affinity configured
- App instances listening on 6pn
Haproxy makes it very easy to configure load balancing across
<region>.<appname>.internal, we use this for our postgres clusters: postgres-ha/haproxy.cfg at main · fly-apps/postgres-ha · GitHub
--max-per-region is a neat command shared with me for future readers.
Full command looks like
fly scale count 6 --max-per-region 1