Search Sreeni's Insights

Filter by content type
cloud May 5, 2016 7 min read

Designing a multi-region application on Azure - traffic manager and failover

Multi-region Azure application design explained through Traffic Manager routing, primary and secondary regions, SQL replication, latency, health checks and failover practice.

Share:

Designing a multi-region application on Azure - traffic manager and failover

A global audience is not becoming closer to an origin server because the application is deployed in Azure. A user in Asia is still travelling across networks to North Europe, and a regional outage is still affecting every user when there is one deployment boundary. In the previous article, we discussed serverless execution and where Azure Functions is fitting. In this article, we are going to design a two-region application with Traffic Manager, a primary region, a secondary region and a clear failover process.

TL;DR Summary

  • Multi-region design starts with availability, latency and data requirements, not by copying a Web App.
  • Azure Traffic Manager is DNS based, so resolver caching is affecting how quickly traffic is moving.
  • Priority routing keeps one endpoint primary and another endpoint on standby.
  • Performance routing is selecting the endpoint with the lowest measured latency for the user.
  • Weighted routing is useful for gradual distribution or testing, but it is not a replacement for health validation.
  • SQL active geo-replication and application failover are separate responsibilities.
  • The secondary region must be deployed, monitored and exercised before the incident.

Challenges

DNS failover is not instant

Traffic Manager is returning DNS answers. A resolver or client can cache an answer until its time-to-live is ending, so changing the Traffic Manager profile is not switching every user immediately. This is different from a load balancer which is already in the request path. The runbook must state the expected delay.

Two regions can create two truths

A Web App can be copied quickly, but fund prices and unit holdings are having business meaning. If both regions accept writes without a conflict policy, failover is creating a reconciliation problem. The design must identify the write owner, the replication direction and the acceptable stale data.

A standby can be stale

A secondary endpoint which is never tested can have an old certificate, an incomplete deployment, a missing Key Vault permission or a database schema which is not matching production. The team may be having two infrastructure copies but only one usable service. Health checks must include the dependencies which matter to a customer request.

What is a multi-region application?

A multi-region application is deployed across two or more Azure regions with a defined traffic, data replication and recovery strategy.

In simple terms, we are keeping a second place ready for the application and deciding how users will reach it when the first place is not healthy. Traffic Manager is one part of this design, not the whole design.

An everyday analogy is a hospital with a second clinic. The second clinic is useful only when it has staff, records, equipment and a route for patients. A sign saying “another clinic exists” is not a recovery plan.

Why multi-region design is important?

The design is important when regional failure, user latency or regulatory separation is creating a business requirement. It can improve resilience, but it is also multiplying deployment, monitoring and data responsibilities. We should not pay the complexity cost unless the expected business loss is higher than the cost of operating another region.

Traffic Manager routing methods

Traffic Manager provides several routing choices which must be selected against the business requirement:

MethodBehaviourExample
PriorityUses the first healthy endpoint, then the next priorityNorth Europe primary, West Europe failover
PerformanceSelects the endpoint with the lowest network latency for the userAsia users reach the lower-latency region
WeightedDistributes according to configured weightsSend a small percentage to a new endpoint

Priority is easier to reason about for a single write owner. Performance is useful when both regions can serve the same data safely. Weighted routing is useful for a controlled trial, but we should not use it as a substitute for application health checks.

The following diagram depicts users reaching Traffic Manager, which is selecting North Europe as the primary endpoint:

Multi-region Azure architecture
Multi-region Azure architecture

Both regions contain a Web App and SQL Database. The purple path is the normal Users → Traffic Manager → North Europe route. The dashed route labelled Failover is showing the secondary endpoint, and the dashed Geo-replication edge is showing the database relationship. Traffic routing and data replication are intentionally drawn as different concerns.

Data and application failover

SQL active geo-replication is allowing a database to have a readable secondary database in another region. It is not making every application write active-active. In our case, North Europe is the write owner for fund prices, and West Europe is receiving replicated data. A failover procedure must state when the secondary is promoted and how the connection string is changed.

The Web App deployment must be identical in both regions. Configuration is different only where it is region-specific, such as the database endpoint, storage account and telemetry resource. A health probe should check the application and a small read-only query, not only whether the web process is returning HTTP 200.

1. Detect the region or dependency failure.
2. Check Traffic Manager endpoint health and the last replicated data point.
3. Confirm the business owner accepts the RPO for the secondary.
4. Promote or enable the secondary data path.
5. Update the application configuration and validate a known fund query.
6. Change the Traffic Manager priority or endpoint status.
7. Watch errors, DNS movement and customer reports.

This process requires an operator decision because automatic failover can make a data problem worse. The runbook should include the name of Fund 123, a known price and a known news article so the validation is not only checking that the server has started.

Trade-offs

StrategyProsCons
Single region+ Lower cost<br>+ One data owner− Regional outage is a major incident<br>− Global latency may be higher
Primary/secondary+ Clear write ownership<br>+ Lower conflict risk− Secondary capacity can be underused<br>− Failover needs testing
Active-active+ Both regions use capacity<br>+ Lower dependency on one endpoint− Distributed writes and conflicts are difficult<br>− Operations are more expensive

In our case, we are starting with primary/secondary, priority routing and SQL active geo-replication. We are considering performance routing only when both regions are serving the same consistency model. Follow the following instructions: write the RTO, RPO, routing method and operator action in the design record, otherwise “multi-region” is only describing infrastructure duplication.

Testing the regional design

The failover exercise is starting with a planned change, not a surprise outage. We are lowering or disabling the primary endpoint, checking that Traffic Manager is returning the expected DNS answer after the TTL, and validating that the secondary Web App can read Fund 123. We are recording the time from the decision to the first successful business request. A successful DNS change without a successful fund query is not a recovery.

The deployment pipeline publishes the same artifact to both regions. A region-specific setting comes from the environment, and a configuration comparison shows unexpected differences. The secondary SQL database is checked for replication lag, and the runbook records which price was last received. If the price is outside the agreed RPO, the product owner decides whether traffic should remain closed.

Returning to the primary region is another change, not an automatic reward after the incident. The team is first confirming that the original region is healthy, that data written in the secondary is reconciled and that the Traffic Manager priority can be changed without creating a split-brain write path. The operator is then watching both regions during the change.

Traffic Manager does not replace a real user check. A health probe can return 200 while the application cannot query SQL or Key Vault. The probe endpoint therefore checks a lightweight dependency path, while a synthetic transaction reads a known fund and records the result. These checks are displayed in the operations dashboard.

Must Do and Don’ts

  • Must Do: Set Traffic Manager health checks against a meaningful endpoint, otherwise a live web process can receive traffic while SQL is unavailable.
  • Must Do: Test DNS TTL and resolver behaviour, because changing the profile will not instantly change every cached answer.
  • Must Do: Exercise the secondary deployment and database path, otherwise drift will be discovered during the outage.
  • Must Do: Record the last replicated price and acceptable RPO, so the failover decision is based on business data.
  • Don’t: write independently in both regions without a conflict design, otherwise the two regions will create competing prices or holdings.
  • Don’t: call SQL replication a complete DR plan, because secrets, storage, queues, deployment and operator steps still need recovery.

Wrap up

In this article, we have looked at Traffic Manager priority, performance and weighted routing, SQL active geo-replication, DNS behaviour and a primary/secondary failover runbook. A second region is useful only when it is kept ready and tested. I hope this article provided you some insights into multi-region design. In the next article, I will walk you through Disaster Recovery on Azure, including RTO, RPO and backups.

Related Posts