# Data centers

The picture below shows an example setup with two data centers. In normal operation, users are geoDNS-routed, also known as geo-routed, to the closest data center, with a split traffic of x% in US-East and (100 – x)% in US-West. geoDNS is a DNS service that allows domain names to be resolved to IP addresses based on the location of a user.

<figure><img src="https://1722711354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwNXdoUkfmcozr29fRrfb%2Fuploads%2FKXZTEX3fidR2aawMjymd%2FScreenshot%202023-11-08%20at%2019.02.33.png?alt=media&#x26;token=2cf223af-0459-4e1b-bdf2-e937023f08e8" alt=""><figcaption></figcaption></figure>

In the event of any significant data center outage, we direct all traffic to a healthy data center. In the picture below, data center 2 (US-West) is offline, and 100% of the traffic is routed to data center 1 (US-East).

<figure><img src="https://1722711354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwNXdoUkfmcozr29fRrfb%2Fuploads%2FA21kMsRtqHxcwc3dcT7c%2FScreenshot%202023-11-08%20at%2019.04.33.png?alt=media&#x26;token=df812305-7284-40f7-961f-14540db4dc6c" alt=""><figcaption></figcaption></figure>

Several technical challenges must be resolved to achieve multi-data center setup:

* Traffic redirection: Effective tools are needed to direct traffic to the correct data center. GeoDNS can be used to direct traffic to the nearest data center depending on where a user is located.
* Data synchronization: Users from different regions could use different local databases or caches. In failover cases, traffic might be routed to a data center where data is unavailable. A common strategy is to replicate data across multiple data centers. A previous study shows how Netflix implements asynchronous multi-datacenter replication.
* Test and deployment: With a multi-datacenter setup, it is important to test your website/application at different locations. Automated deployment tools are vital to keep services consistent through all the data centers \[11].

To further scale our system, we need to decouple different components of the system so they can be scaled independently. Messaging queue is a key strategy employed by many real- world distributed systems to solve this problem
