- Published on
Traffic Management with DNS: Geo-Routing
- Authors
- Name
- Alex Lee
- @alexjoelee
When you're scaling web applications up, you may decide to run servers in more than one datacenter location. There are numerous advantages, including redundancy and latency. In this article, we're going to cover geo-routing using DNS, enabling you to direct traffic based on a user's location.
What is Geo-Routing?
Geo-routing uses information from a user's DNS request to determine their approximate location and respond with the IP address of the server closest to them. Geo-routing might determine the best server to answer with by testing latency or by measuring distance.
Redundancy in Geo-Routing
Geo-routing also plays a role in failover. For example, you might place servers on both the east and west coasts of the US. If your servers on the west coast are down, your DNS service can instead start answering with the east coast IP addresses. While this might increase load on the east coast servers and increase latency for your west coast users, it's better than being offline
Geo-Routing Example: Distributed Web Application
Let's say that you have a web application with a React-based front end and a Python-based backend. The front end application sends API requests over HTTP to the backend. You might spin up front-end application servers in us-east
, us-west
, and eu-central
with your main backend server in us-east
. You can use a Geo-Routing service to send users to the location closest to them. While your API requests between zones will incur a higher latency, all requests from users to your application will be much lower latency. This set up also makes it much easier to scale up as your user base grows.
Choosing a DNS Service
There are several DNS service providers that offer GeoDNS, Geo Routing, or some other geographic or latency based balancing. Some examples of services that offer this include (but aren't limited to):
- Constellix
- ClouDNS
- Rage4
- DNSimple
- Amazon Web Services Route53
Each one provides different services and pricing depending on the exact project needs. Each one also has excellent uptime and low latency. We use these services to run our own network.