Using the fly-region header we know where the request originated, so let’s say I had a central service that needs to dispatch calls to app instances running in the region where the request originated or the next closest region where an instance is actually running. Apart from maintaining a list of regions and their neighbors in my application what would be the best way to do that?
Hey @kurt thanks for the quick reply! Reading over the docs I’ve seen the capabilities that you mention for sure. My question is more about being able to direct an internal call to a given region or the next nearest one - example - the call came in via the region iad but I’m not running an app instance there, only in ewr. I’d like to be able to route a request internally to iad or the next closest region at some point in the future, i.e. ewr seeing as NJ is closest to VA.
As I write this I realize I might be misunderstanding something fundamental here - I’m asking this a) only having read the docs and not actually tried anything and b) under the assumption that the fly-region header indicates where the request entered the network, which could be in a different region from where your app is actually running, so for my example it entered in iad but got routed to ewr. That could be totally wrong and if so, please disregard!
If I understand correctly, you have an external request coming in for app1 to iad, but since you don’t have a node there it gets forwarded to the ewr region. Then, your app1 in ewr wants to make an internal request to app2 which may have a node in ewr but if it doesn’t then you want to use the next nearest region.
I believe what you’re trying to do can be achieved using top1.nearest.of.app2.internal when making the internal request to app2.
Does this sound like what you’re after? If not, can you provide an example flow of what you’re after.
Hi @charsleysa - can you confirm that what you said happens? The request enters at iad but if I don’t have my app running there it would get forwarded to the closest region such as ewr? Would the fly-region header have iad as the value in that case?
A request coming into iad would have the fly-region set to iad. If there are no nodes in iad then the request is forwarded to the closest available region and the fly-region header stays as iad.
Also note that these headers are only set if the request is coming through the fly proxy. If the request is internal and not going through the fly proxy then the header is not available. Requests from one fly app to another fly app using .internal addresses do not go through the fly proxy.
Nice. Unfortunately I just realized that my thinking here is invalid. The use case I was thinking of was webhooks, and making sure that they are sent from an app instance closest to the region where the request to receive the webhook came from in order to reduce delivery latency. But, just because the request to subscribe to a webhook came in at iad doesn’t necessarily mean that the URL where they want the webhook sent is in the same geographical region. Oh well, sorry for taking up everyone’s time here but thanks for the fast and thorough responses! Really impressed with fly thus far!
This is actually a helpful discussion, so no need to apologize. We’re in the very early days of multi region apps and there’s a lot to figure out (for us AND devs).