Using timezone offset for finding closest server
I am building an open source framework for p2p real-time communication through relays which is supposed to work in web browsers as well as mobile devices. There is no backend, there are a bunch of relays scattered around the world, peers can talk to each other only when connected to the same relay.
Originally I was planning to build an API to get the user’s IP location and return the closest relay. But I decided not to have this single point of failure as the API may not always be accessible.
So I just host a file on GitHub with a list of all active relays and their location. I want to vaguely link a peer to the closest relay to achieve lower latency and load distribution, though if the peer can’t connect to that specific relay it will try the next closest and so on.
I was originally thinking of using the user’s timezone and mapping that to geo coordinates but it will be a very big file and every OS/browser may have a different timezone naming. So I decided to instead just map all the timezone offsets to “average” longitude within the timezone and use that to find closest relay. Is that a crazy idea? Can you guys suggest a better solution?
So with this idea all users in Europe or Africa will have closest longitude to one of the EU servers, users in Asia/Australia will have closest longitude to HK/SG, users in West Coast to LA/Seattle and users on East Coast to NY.