Do unused fly.io instances automatically shut down? (+ other region questions)

Good questions!

I’m assuming you’re running with the autoscaling strategy (default)? This will only spin up instances in a region close to users if there’s sufficient traffic to justify it. This is based on the number of connections established to your app by edge region and over time.

If we do add an instance in Singapore and then connections go back down, we will tear down that instance within a few minutes and rebalance accordingly.

You might be interested in these scaling docs.

There are a few ways! However, I’m not sure it’s possible from the IP.

  • There’s the Fly-Region header added to your requests if you’re using the http handler. That’s the edge region the user hit (and therefore the best* route to our server). *not always best :smiley:
  • curl https://debug.fly.dev returns general information about what edge node you’re hitting and headers that are populated (this special app runs on every server)
  • curl -i https://your-app.fly.dev -H "flyio-debug: doit" returns a header with debug information, but only if you’re using the http handler.
  • A pretty impractical and unreliable way would be to have the user issue a traceroute and sort of figure out from the DNS names where they landed

None of these are ideal, unfortunately. You might be able to use a database like MaxMind to get a rough estimate of the user’s country from their IP and determine which region is geographically closer (but it might not be the best route to us)

There are a few queries you can make, as documented here. For example: yyz.your-app.internal would give you all of your-app instances in Toronto.

A “current region” DNS query might be interesting! Since you already know which region you’re in via environment variables, the region query I just mentioned might be fine.

1 Like