Skip to content

// blog › azure

AZURE · DISASTER RECOVERY

Active/active on Azure with Front Door and Cosmos DB

series Part 6 of 9 · Disaster recovery across AWS, Azure and Google Cloud

On this page
  1. The problem: no time to fail over
  2. The diagram explained
  3. How recovery works
  4. Conflicts and consistency
  5. RTO, RPO and cost
  6. How to choose
  7. When not to use it
  8. How to draw it in archhy
  9. The series
key takeaways
  • Front Door health probes drop an unhealthy region from routing on their own. Nothing has to be promoted.
  • Cosmos DB multi-region writes need no failover step, but rule out strong consistency; a policy you choose settles conflicts.
  • Each region must carry the whole load: two full stacks and per-region database throughput.
  • Replication is not backup. Keep continuous backup for deletions and bad writes.
diagramActive/active on Azure: Front Door, two regions, Cosmos DB multi-region writesOpen this diagram in archhyOpens in a new tab in the editor, ready to change. No account needed.See it in the diagram library →

An Azure active active design runs the same web application in two or more Azure regions at once, with every region serving real users all the time. Azure Front Door sends each request to the nearest healthy region, and Azure Cosmos DB accepts writes in every region and replicates them to the others. When a region fails, the others already carry traffic. This post draws the pattern, what recovers by itself, what needs a person, and the cost.

The problem: no time to fail over

Active/passive designs such as warm standby still need someone, or something, to declare the primary lost and move traffic. RTO (recovery time objective) is how long you can be down; RPO (recovery point objective) is how much data, measured in time, you can lose. If both must be close to zero, make every region primary.

The diagram explained

Users reach one Front Door endpoint on the left. It routes to two regions, each running an identical deployment stamp (open the diagram).

  • Azure Front Door uses latency routing, its default: each edge location sends a request to the origin with the lowest measured latency among the healthy ones. Raising the latency sensitivity (0 ms by default) spreads traffic across more regions.
  • Deployment stamps. Microsoft's mission-critical guidance splits resources into global ones (Front Door, Cosmos DB, global monitoring) and regional stamps. A stamp holds the stateless application, here App Service or AKS, with its own Key Vault and cache. Stamps are independent, keep no long-lived state and are replaced by redeploying. One vault shared by every region would be a global point of failure.
  • Azure Cosmos DB has a write region in each Azure region. The first region on the account is the hub: writes in the other (satellite) regions commit locally, then go to the hub asynchronously to be checked for conflicts.
  • Azure Managed Redis per stamp, with active geo-replication. Azure Cache for Redis is retiring, so new designs use this. A cache is one more thing that can fail.
  • Monitoring: Application Insights per region, feeding a global Log Analytics workspace.

Restrict each App Service to your Front Door profile with the AzureFrontDoor.Backend service tag and the X-Azure-FDID header.

How recovery works

  1. Detect. Every Front Door edge location probes every origin, every 30 seconds by default. Only a 200 OK counts as healthy; an origin is healthy when enough of its last few probes succeed. Probe a health endpoint that checks what the stamp needs, such as its database.
  2. Fail over. Front Door stops sending traffic to the failed origin. Failed connections get a best-effort retry elsewhere, not a guaranteed one. In Cosmos DB, the SDK sees the region is unhealthy and moves reads and writes to the next region in your preferred list. Microsoft states no expected downtime when the SDK is configured this way.
  3. Scale. Survivors take all the load: size stamps and Cosmos DB throughput for it, or use autoscale.
  4. Fail back. When probes pass again, Front Door routes to the region again. Unreplicated writes appear in the Cosmos DB conflict feed for your application to resolve.

What needs a person: Microsoft does not notify you when a region is down, so set up Resource Health alerts. People drain a degraded region that still passes probes, redeploy stamps, reconcile the conflict feed and restore after a bad write.

Conflicts and consistency

Cosmos DB recognises insert, replace and delete conflicts. The default policy is last writer wins on the system timestamp; with the API for NoSQL you can name your own numeric property instead. A delete always beats an insert or replace. A custom policy runs a merge stored procedure (unhandled conflicts go to the conflict feed) and can only be set when the container is created.

Keep each region's traffic local. Reading in one region what you wrote in another ties you to replication lag. Avoid rapid repeated updates to one document.

RTO, RPO and cost

  • RTO: as long as Front Door takes to mark the region unhealthy, with no database failover step.
  • RPO: Microsoft gives less than 15 minutes for session, consistent prefix and eventual consistency, and for bounded staleness the configured lag (at least 100,000 writes or 300 seconds). Strong consistency would give zero, but it is not available with multiple write regions.
  • Cost: two or more full-size stacks running all the time. Cosmos DB bills throughput per region, so two write regions cost about twice as much as one. Redis geo-replication adds data transfer between regions.

How to choose

  • Choose it when downtime is very expensive and the data can converge eventually.
  • If you need strict consistency, use a single write region with read replicas, and accept a write failover. Service-managed failover can take an hour or more; a forced (offline region) failover is faster but needs you to trigger it.
  • Drill it: take a Cosmos DB region offline on purpose and watch the application.

When not to use it

  • Strongly relational, transactional data: multi-region writes do not fit.
  • An RTO of hours: backup and restore or warm standby costs far less.
  • The app is not yet stateless and zone-redundant in one region.

How to draw it in archhy

  1. Open the Services drawer, pick the Azure pack, and place two Region containers, one above the other.
  2. In each region add a Resource group container named "Deployment stamp" holding App Service, Azure Managed Redis and Key Vault; put Cosmos DB and Application Insights beside it and Front Door on the left.
  3. Draw rails from Front Door to each App Service. Draw a green rail between the Cosmos DB nodes with arrows at both ends, and make the operator's rail dashed.
  4. Add an info box to each Cosmos DB node with its role and RPO, then use File ▸ Download PNG for the runbook.

The series

This post is part of Disaster recovery across AWS, Azure and Google Cloud:

  1. RTO, RPO and the four disaster recovery strategies
  2. Backup and restore (cold DR) on AWS
  3. Pilot light vs warm standby on AWS
  4. Multi-site active/active on AWS
  5. Warm standby on Azure with Site Recovery
  6. Active/active on Azure with Front Door and Cosmos DB (this post)
  7. Cold, warm and hot DR on Google Cloud
  8. From your data centre to the cloud: DR into AWS, Azure and Google Cloud
  9. DR building blocks compared: AWS vs Azure vs Google Cloud

Frequently asked questions

Does Azure Front Door fail over automatically?

Yes. Its health probes mark an origin unhealthy when it stops returning 200 OK, and traffic goes to the remaining healthy origins with no manual step.

What happens to Cosmos DB writes when a region fails?

With multiple write regions, the SDK moves reads and writes to the next region in its preferred list. Writes that had not replicated reappear in the conflict feed when the region returns.

Can I use strong consistency with multi-region writes?

No. Accounts with multiple write regions cannot use strong consistency, so you choose a weaker level and a conflict resolution policy.

Do I still need backups in an active/active design?

Yes. Replication copies deletions and bad writes to every region. Continuous backup lets you restore to a point before the damage.

based on Redrawn and discussed from Architecture pattern for mission-critical workloads on Azure (Microsoft Azure Well-Architected Framework), with the Azure Front Door and Azure Cosmos DB documentation listed in the sources. The diagram, the choosing guide and the commentary are archhy's own.