esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

Geodes: Identical Copies of a Service in Many Regions, Each Able to Serve Anyone

A geode is an identical copy of a service placed in one region. Users go to the nearest healthy copy, and the copies share their data.

In short

A geode is an identical copy of a service placed in one region; users go to the nearest healthy copy, and the copies share their data.

11 min readFree

What you will learn

Many apps start in one cloud region, which is a group of data centers in one geographic area. That works until users live far away, or until the whole region has a bad day. The geode pattern is one answer. It runs the same service in several regions, and any copy can handle any user's request. In this lesson you will learn what a geode is, how data moves between geodes, how a worked example plays out, and what the pattern costs.

Key words

Region
One geographic area where a cloud provider runs data centers, such as US East or Western Europe.
Latency
The delay between sending a request and getting the reply.
Geode
One full, identical deployment of a service in one region. The name comes from geographical nodes.
Replication
Copying data from one machine or region to others so they all hold it.
Replication lag
The short delay before a copy receives a change that was made somewhere else.
Strong consistency
A rule where every read sees the latest confirmed write.
Eventual consistency
A rule where copies agree after a while, but a read may show older data for a short time.
Conflict
Two copies change the same item at about the same time, so the system must pick or merge the results.
Failover
Sending work to another working part when the main part stops.

What is a geode?

A geode is one complete deployment of a backend service in one place. The service is deployed to several geographic locations, and each deployment is a geode. Any geode can answer a request from any user, no matter which region that user is in. The pattern is active-active, which means every copy is live and taking traffic at the same time, not waiting as a spare.

The pattern is built around one idea: bring the compute to the data. Older designs kept data in one remote database and sent every request there. That adds distance for far-away users, and it makes one place a single weak spot. With geodes, each copy of the app sits near a local copy of the data, so requests stay short.

What is the core design?

  • Identical copies

    Every geode is built from the same template, so the parts match. Teams deploy all of them with the same scripts, which keeps them alike.

  • Self-sufficient

    A geode has the regional resources it needs to finish a request. It does not depend on another geode's app layer, so if one geode dies, the others keep running.

  • Front door routing

    A global routing service sits in front of all geodes. It checks their health and sends each user to a suitable one. No single primary region has to be up for the system to work.

The routing layer and the data layer are shared. The geodes are loosely linked through routing and replication, not by calling each other on every request. That loose link is why one failure does not spread far.

How does routing to the nearest healthy geode work?

  1. 1

    Request arrives

    A user opens the app. The request first reaches the global routing service, which might be a DNS-based or edge network product.

  2. 2

    Health check

    The router keeps checking whether each geode answers correctly. A geode that fails the checks is removed from the choices until it recovers.

  3. 3

    Pick the nearest

    Among the healthy geodes, the router chooses the one with the shortest network path to the user.

  4. 4

    Serve from there

    The chosen geode handles the request using its local copy of the data, so the reply comes back quickly.

  5. 5

    Shift on failure

    If that geode fails later, the next request goes to the next-nearest healthy geode. Users may be moved to another geode, but availability depends on healthy shared dependencies and enough compute and database capacity in the surviving geodes.

Here is a small model of that choice. The numbers are made up for the demo. The code picks the closest geode that is still up.

Python
# Made-up demo numbers: milliseconds from one user to each geode.
latency_ms = {"us": 120, "europe": 25, "asia": 210}
healthy = {"us": True, "europe": True, "asia": True}

def pick_geode(latency, alive):
    up = [name for name in latency if alive[name]]
    return min(up, key=lambda name: latency[name])

print(pick_geode(latency_ms, healthy))
healthy["europe"] = False
print(pick_geode(latency_ms, healthy))

Output

europe
us

How does the data work?

Running the app code in many places is the easy part. Data is harder. Each geode reads and writes through a data store that is replicated across regions. A write made in one region is copied to the others. In Azure's example, a Cosmos DB account with multiple write regions lets each geode read and write in its own region, and those writes copy to other regions in the background. That background copy is called asynchronous replication, because the write does not wait for the copies to finish.

Waiting for copies to catch up

Because copying takes time, another geode may briefly show an older version of an item. The app has to expect this. It gets worse when one user's next request lands on a different geode. A common fix is a session token. The client keeps a small token from its last write and sends it with later reads, so it can see its own changes even after it moves to another geode. The Cosmos DB guidance says the shared token should be used for reads only in multi-region-write accounts.

Should you choose strong or eventual consistency?

Consistency is the rule for what readers are allowed to see. With strong consistency, every read returns the latest confirmed write. That is safe, but across long distances it is slow, because a write must wait for other regions to agree. With eventual consistency, copies agree after a while. Reads are fast and cheap, but a reader may see old data for a moment. The geode pattern usually leans toward eventual consistency, and then the app is designed to cope with stale reads.

When two regions change the same item

Take a product with 10 items in stock. A shopper in New York reads 10, subtracts one, and writes 9. At nearly the same moment, a shopper in London also reads 10, subtracts one, and writes 9. Two sales happened, but the stock shows 9. This is a conflict. Cosmos DB's default rule is last writer wins. The write with the highest value in a chosen field, by default a server timestamp, is kept, and the others are discarded. Conflicts settled this way do not show up in the conflict feed, so nobody is alerted.

Tip

Last writer wins can silently drop a real sale. For money, stock, or anything you cannot afford to lose, use a custom rule, a version check, or a merge that combines both changes.

The model below uses the same rule: keep the write with the highest timestamp. The numbers are made up for the demo.

Python
# Two regions changed the same item. Keep the write with the highest timestamp.
writes = [
    {"region": "us", "value": "quantity 9", "ts": 1001},
    {"region": "europe", "value": "quantity 8", "ts": 1002},
]
winner = max(writes, key=lambda w: w["ts"])
print(winner["region"], winner["value"])

Output

europe quantity 8

Worked example: a messaging app in three regions

Imagine a chat app with identical backends in the US, Europe, and Asia. Each has its own app servers and a local copy of the message store. Follow one message sent by a user in Berlin.

  1. 1

    Berlin user is routed

    The routing service sees the user in Berlin. The Europe geode is healthy and closest, so the user connects there.

  2. 2

    Message saved locally

    The Europe geode writes the message to its own copy of the data. The write stays in Europe, so the sender gets a quick reply.

  3. 3

    Copies catch up

    The data store copies the message to the US and Asia copies in the background. For a short time, a reader in Tokyo may not see it yet.

  4. 4

    Europe fails

    The Europe geode stops passing health checks, so the router removes it. Suppose the US geode is the next-nearest one. The Berlin user's next request goes there, and the message is already in that copy.

  5. 5

    Europe recovers

    When Europe passes health checks again, the router can send Berlin users back. The Europe copy must first catch up on anything it missed, and the app must tolerate that catch-up period.

The message survived the failure only because it had been copied before Europe went down. If Europe had failed in the moment between the save and the copy, the message could have been lost. That is why the write path and the copy path need to be designed together.

When to use geodes

Use this pattern when the cost of distance or downtime is high. Three cases fit it well.

  • Global users

    Users spread across several continents all expect fast replies, and a single distant region makes some of them wait.

  • Latency-sensitive apps

    Games, chat, and live tools feel every extra fraction of a second, so the copy near the user matters.

  • Regional failover

    If one region goes dark, the other geodes keep serving. Losing one geode only shifts its traffic, provided the others have spare capacity.

Be careful with rules about where data may live. If a law or contract keeps some data inside one country, a copy in every region may be the wrong design for that data.

Costs and trade-offs

  • Money

    Every region needs compute and database capacity, so the bill grows with each geode. Autoscaling and pay-per-use compute can cut idle capacity, but they do not make the copies free.

  • Consistency work

    The app must handle replication lag, stale reads, and conflicts.

  • Legal and residency limits

    Some data may need to stay in one place, which limits which geodes can hold it. Plan this before you choose regions.

  • Same version everywhere

    All geodes should run the same release. If one region gets a new version first, users may see different behavior depending on where they land. Build every geode from the same template and roll out changes in a controlled way.

Tip

Test a regional failure under realistic load before you rely on it. Check that the surviving geodes can carry the redirected traffic, and test failback, which means sending traffic back to a recovered region.

Compare this with active-passive designs. In those, one region takes writes and a standby waits. Pick the model that matches the failure you must survive.

Check your understanding

Try these two new scenarios. Each one needs the ideas from this lesson.

Quick check

A video game has a global leaderboard, but every server sits in one US region. Players in Australia see slow replies, and the whole game goes down when that region fails. Which change fixes both problems, and what new problem must you handle with the scores?

Quick check

A user in Paris changes her display name on the Europe geode. Soon after, the Europe geode fails, and her next request goes to the US geode before the change has copied there. Without any extra design, what is the most likely result?

Sources

How is this lesson?

Last updated on 18 November 2026

Learn with me

Every lesson is free. I add new ones as I learn. Have a question, or want help with your own work? Book a short call.