I just started using workers a couple of days ago to do some load balancing and failover depending on region of the request. This works great as I can send traffic from APAC to Sydney and everyone else (for the moment) to New York, with the potential to expand to other locations, such as Europe, as required.
While I was writing the worker I thought about how I can find out which location to send the user to, currently I am using the
cf-ipcountry header and matching that up to country.io data for continents.
This works, but is lacking a bit of granularity, for example I can’t differentiate if someone is on the west or east coast of the USA and send them to a closer server (NY vs SF)
Would it be possible for workers to gain the ability to know which PoP they are being executed from (maybe some sort of environment variable that could be accessed?)
This would make workers even more powerful!
Just a quick note: I can’t use DNS load balancing because I only want/need load balancing on specific routes currently (cost saving mainly)
On the surface this sounds quite simple, but I am sure workers are much more complex under the hood