Support for fly-prefer-instance

I’m trying to make a request from one instance of my app to the other. I determine the instance ID based on the .primary directory provided by LiteFS. Unfortunately, I don’t have any way for instance “B” of my app to know what region instance “A” is in, so I can’t make the request with the fly-prefer-region header. I tried with fly-prefer-instance, but that did not send the request to the instance I specified.

Is there any way to do this?

My specific use case is to copy a cache db (sqlite) on startup of a new instance with a new volume so it does not have to warm up the cache itself.

There is fly-force-instance-id. However this won’t try any other instance of it fails.

Our internal dns might help here. We have a TXT record for regions.APP_NAME.internal that returns all regions that an app is deployed. There is also a TXT record for vms.APP_NAME.internal that returns instance ids and their region.

For example, fly ssh console into a running app and make sure dig is installed:

dig TXT regions.$FLY_APP_NAME.internal +short
dig TXT vms.$FLY_APP_NAME.internal +short

Thanks @jerome and @tvdfly! Those options are helpful.

For my specific case, I realized that I actually don’t care which region responds to the request so long as it’s a currently running region that’s taking traffic it should have the cache database available for me to download, so I actually just hit $FLY_APP_NAME.fly.dev directly and let fly send that to any region it wants.

1 Like