The System Design Newsletter

The System Design Newsletter

Share this post

The System Design Newsletter
The System Design Newsletter
How Halo Scaled to 11.6 Million Users Using the Saga Design Pattern 🎮
Copy link
Facebook
Email
Notes
More
User's avatar
Discover more from The System Design Newsletter
Download my system design playbook for free on newsletter signup
Over 154,000 subscribers
Already have an account? Sign in

How Halo Scaled to 11.6 Million Users Using the Saga Design Pattern 🎮

#51: Break Into Saga Design Pattern (4 Minutes)

Neo Kim's avatar
Neo Kim
Jul 04, 2024
155

Share this post

The System Design Newsletter
The System Design Newsletter
How Halo Scaled to 11.6 Million Users Using the Saga Design Pattern 🎮
Copy link
Facebook
Email
Notes
More
23
12
Share

Get my system design playbook for FREE on newsletter signup:


This post outlines the Saga design pattern. You will find references at the bottom of this page if you want to go deeper.

  • Refer just 3 people & I'll send you some rewards as a thank you.

Saga design pattern is often used to achieve data consistency and reliability in distributed systems. Microsoft now owns the Halo game series.

Once upon a time, a game development company named Bungie made a strategy game.

Yet they didn’t have success with it.

So they pivoted to create a shooting game and called it Halo.

They used a single SQL database to store the entire game data.

But their growth rate was incredible.

saga design pattern

And it became difficult to store all data in a single database.

So they set up a NoSQL database and partitioned it.

While each game can have up to 32 players.

And each player’s data gets stored in a different database partition.

Storing Game Data Across Database Partitions
Storing Data Across Database Partitions

Although it temporarily solved their scalability issue, it created new problems.

Here are some of them:

1. Atomicity:

Each player in the same game must see the correct game points. That means atomic writes.

Atomicity is the idea that the writes to every partition succeed or no writes happen at all.

Yet there’s a risk of database partition failure.

This means a failed partition will have wrong data due to missing writes.

So it’s hard to achieve atomicity with a partitioned database.

2. Consistency:

Consistency means changing data from one valid state to another valid state.

Yet there’s a risk of network latency and network failures.

That means some partitions will contain outdated data.

So it’s hard to achieve consistency with a partitioned database.

system design newsletter

Saga Design Pattern

They wanted a simple & scalable failure management pattern.

So they set up Saga.

Here’s how Saga works:

1. Divide & Conquer:

It splits a transaction into sub-transactions.

And assigns a separate sub-transaction to each database partition.

That means it still looks like a single transaction.

Saga Applying Compensating Transactions on a Failed Sub-Transaction
Saga Applying Compensating Transactions after a Failed Sub-Transaction

Besides a revert action is available for each sub-transaction - compensating transaction. It’s like a correction and not an undo. For example, canceling a hotel booking instead of removing it.

  • The compensating transactions get executed only if a sub-transaction fails.

  • The compensating transactions must be idempotent, so retries are possible without side effects.

2. Interacting with Database Partitions:

They set up a separate service to manage sub-transactions and called it Orchestrator.

Controlling Sub-Transactions Using Saga Orchestrator
Saga Orchestrator Controlling Sub-Transactions

It let them:

  • Control sub-transactions

  • Apply compensating transactions if needed

3. State Information:

It’s necessary to store each sub-transaction's state (start & end) outside Orchestrator.

Otherwise it will become a single point of failure.

So they use a durable and distributed log.

Distributed Log Storing State of Saga Sub-Transactions
Storing State of Sub-Transactions in Log

It let them:

  • Track if a sub-transaction failed

  • Find compensating transactions that must be executed

  • Track the state of compensating transactions

  • Keep the orchestrator stateless

  • Recover from failures


TL;DR:

High Level Architecture of Saga Design Pattern
High-Level Architecture of Saga Design Pattern
  • Orchestrator: manages sub-transactions & interacts with log

  • Log: stores the state of each sub-transaction

  • Compensating transaction: idempotent for retries & revert failure

system design newsletter

🔥 Use Cases:

Saga is often used to maintain data consistency in a microservices architecture. And it prevents tight coupling.

Here are some real-world use cases of the Saga design pattern:

  • E-commerce app: placing an order after checking inventory and payment status.

  • Travel booking system: guaranteeing combined reservation of flights, hotels, and rental cars.

  • Banking system: transferring money from one user account to another.


Saga doesn't acquire locks on remote resources and uses compensation to handle failures. Thus it scales well.

It’s a good architectural choice when new database partitions get added over time.

While Halo remains a popular game series for Xbox with millions of unique users.


Subscribe to get simplified case studies delivered straight to your inbox:


Author NK; System design case studies
Follow me on LinkedIn | YouTube | Threads | Twitter | Instagram

Thank you for supporting this newsletter. Consider sharing this post with your friends and get rewards. Y’all are the best.

system design newsletter

Share


Why Is Redis a Distributed Swiss Army Knife 💭

Why Is Redis a Distributed Swiss Army Knife 💭

Neo Kim
·
June 20, 2024
Read full story
How Instagram Scaled to 2.5 Billion Users

How Instagram Scaled to 2.5 Billion Users

Neo Kim
·
June 11, 2024
Read full story

References

  • Applying the Saga Pattern • Caitie McCaffrey • GOTO 2015

  • Microservices Architecture - Saga

  • 10 microservices design patterns for better architecture

  • 7 Microservices Benefits and How They Impact Development

  • Saga distributed transaction pattern

  • Saga Pattern in Microservices

  • Saga pattern - AWS

  • Two-phase commit protocol

  • Sagas - whitepaper

  • Halo (franchise)

Dilshan De Zoysa's avatar
Chirag patel's avatar
Farhadur Reza Fahim's avatar
Raul Junco's avatar
Andrew Opio's avatar
155 Likes∙
12 Restacks
155

Share this post

The System Design Newsletter
The System Design Newsletter
How Halo Scaled to 11.6 Million Users Using the Saga Design Pattern 🎮
Copy link
Facebook
Email
Notes
More
23
12
Share

Discussion about this post

User's avatar
Raul Junco's avatar
Raul Junco
Jul 4

SAGA in action, one of my favorites, Neo!

Expand full comment
Like (2)
Reply
Share
1 reply by Neo Kim
Uriel Bitton's avatar
Uriel Bitton
Dec 3

super interesting design pattern. I love hearing of stories of SQL to NoSQL migrations for various reasons, and the simplicity of your writing :)

Great article Neo !

Expand full comment
Like (1)
Reply
Share
2 replies by Neo Kim and others
21 more comments...
8 Reasons Why WhatsApp Was Able to Support 50 Billion Messages a Day With Only 32 Engineers
#1: Learn More - Awesome WhatsApp Engineering (6 minutes)
Aug 27, 2023 â€¢ 
Neo Kim
742

Share this post

The System Design Newsletter
The System Design Newsletter
8 Reasons Why WhatsApp Was Able to Support 50 Billion Messages a Day With Only 32 Engineers
Copy link
Facebook
Email
Notes
More
24
How PayPal Was Able to Support a Billion Transactions per Day With Only 8 Virtual Machines
#30: Learn More - Awesome PayPal Engineering (4 minutes)
Dec 26, 2023 â€¢ 
Neo Kim
250

Share this post

The System Design Newsletter
The System Design Newsletter
How PayPal Was Able to Support a Billion Transactions per Day With Only 8 Virtual Machines
Copy link
Facebook
Email
Notes
More
14
How Stripe Prevents Double Payment Using Idempotent API
#45: A Simple Introduction to Idempotent API (4 minutes)
May 9, 2024 â€¢ 
Neo Kim
383

Share this post

The System Design Newsletter
The System Design Newsletter
How Stripe Prevents Double Payment Using Idempotent API
Copy link
Facebook
Email
Notes
More
30

Ready for more?

© 2025 Neo Kim
Publisher Privacy
Substack
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More

Create your profile

User's avatar

Only paid subscribers can comment on this post

Already a paid subscriber? Sign in

Check your email

For your security, we need to re-authenticate you.

Click the link we sent to , or click here to sign in.