System design paper · 2019

Zanzibar

Pang, Cáceres, Burrows, Chen, Dave, Germer, Golynski, Graney, Kang, Kissner, Korn, Parmar, Richards and Wang · USENIX ATC 2019

How Google answers “may this person open this?” millions of times a second: permissions as small facts, rules that join them, and a token that keeps changes in order.

A check tries every route to the permission at once: grants on the document, other roles on it, and the folder that holds it. One yes is enough, and the other routes are cancelled.

You’ll learn to

  • Read and write permissions as relation tuples, and walk a check through a rule that makes one relation include others.
  • Explain the “new enemy” problem and how a token saved with the content keeps a removed person out.
  • Describe how an index of flattened groups, caching, merged duplicate requests and hedging keep checks fast.
  • Compare what SpiceDB, OpenFGA and Ory Keto say they took from Zanzibar, and what each left behind.

Read first: Spanner

The idea in short

Every time you open a shared file, some service must decide whether you may. Google runs one such service for Drive, Photos, YouTube, Calendar and more. It stores each grant as a small fact, such as “Ana is an editor of this document”, and keeps a short rulebook that says how facts combine: an editor may also view, and anyone who may view the folder may view what is inside it.

The hard part is order. If Alice removes Bob and then adds a secret page, a check that runs on out-of-date data could still let Bob in. Every content change therefore stores a token marking when it happened, and every later check must look at data at least that fresh. Most checks still run on nearby copies, so the answer takes about 3 ms in the middle and stays up 99.999% of the time.

The problem

Open a shared document and, before a single word appears, something has decided that you may see it. That decision is : deciding whether a person may do a given thing to a given object. (Authentication is the step before it, proving who the person is.) Photo-sharing is the paper’s own example: owners share some photos with friends and keep others private, so the service must check each photo against each viewer before showing it.

By 2019 hundreds of client services at Google needed this answer, among them Calendar, Cloud, Drive, Maps, Photos and YouTube. The authors argue that one shared system beats one per service: permissions mean the same thing everywhere, products can work together, and the hard parts, consistency and scale, are solved once.

The paper gives five goals: correctness, flexibility, low latency, high availability and large scale. The numbers explain why each is hard:

  • Scale. More than 2 trillion permission records, close to 100 terabytes, copied to more than 30 places around the world. More than 10 million requests a second. Over 1,500 separate namespaces (one per kind of object, such as documents or groups), defined by hundreds of client applications.
  • Latency. A check sits in the path of everything a person does. A search result page may need tens to hundreds of checks, one for each candidate result.
  • Availability. If the service cannot answer, a product has to refuse access, which looks to the user like a broken product.
  • Correctness. Permissions change all the time, and the answer must respect the order of those changes. The next sections show what goes wrong when it does not.

So the question the paper answers is: how do you build one authorization service that is flexible enough for every product, honest about the order of changes, and fast and always on, across the whole world?

The design choices

Five decisions shape everything else.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan

About the paper

Zanzibar: Google’s Consistent, Global Authorization System by Pang, Cáceres, Burrows, Chen, Dave, Germer, Golynski, Graney, Kang, Kissner, Korn, Parmar, Richards and Wang, USENIX ATC 2019.

Read the original paper

More System design papers

All papers