Design Facebook Post Privacy
Understanding the Problem
🔒 What is post privacy? Every Facebook post has an audience: Public, Friends, Friends of friends, Only me, or a Custom audience built from specific people and friend lists, with exceptions ("Friends except Alex"). The system has to make sure that a post only ever reaches people in its audience, everywhere it can appear: the author's profile, other people's feeds, search, a shared link, comments and notifications. And when the author tightens the audience, unfriends someone or blocks them, the change has to take effect right away.
Instagram asks the same question with different rules. Visibility there is mostly set per account: a private account's posts are visible only to approved followers. Stories add per-story audiences like Close Friends and a "hide story from" list. Underneath, both products answer one question: can viewer V see object O, given the author's settings and the social graph? We'll design the Facebook model and then show how Instagram's rules plug into the same check.
Functional Requirements
Core Requirements
- Authors should be able to choose an audience when they post (Public, Friends, Friends of friends, Only me, Custom) and change it later.
- Viewers should only see posts they're allowed to see, on every surface: profile, feed, search, permalinks, comments and notifications.
- Authors should be able to build custom audiences from friend lists and individual people, including exclusions.
- Instagram users should be able to make their account private, approve followers, and share stories with Close Friends or hide them from specific people.
Below the line (out of scope)
- Groups, Pages and events, which have their own membership models.
- Privacy for messages and for profile fields (birthday, phone number).
- Ads targeting and data-use controls.
Non-Functional Requirements
Core Requirements
- The system must never show a post to someone outside its audience. When in doubt, it should deny (fail closed).
- Privacy changes (audience edits, unfriending, blocking, going private) should take effect within seconds on every surface.
- Checks must be cheap. A feed request evaluates hundreds of candidate posts, and privacy can only add a few milliseconds to it.
- The system should scale to 2 billion users and 500M daily active users, with an average of 300 friends and a cap of 5,000.
Below the line (out of scope)
- Content that has already left the platform (screenshots, downloaded copies). No access-control system can pull those back.
- Multi-region consistency beyond "a privacy change replicates to all regions within seconds."
Let's size the checks, because that's what drives the design. Say each daily user loads their feed 10 times, and each load ranks about 200 candidate posts that each need a check:
- 500M × 10 × 200 = 1 trillion checks a day, or about 11.6M checks per second on average, before counting profiles, search and comments.
- That's about 58k feed requests a second, each needing a batch of ~200 checks.
At this rate, a privacy check can't be a database query. It has to be an in-memory evaluation against cached graph data, batched per request.
The social graph is large but cacheable: 2B users × 300 friends = 600B directed friend entries, about 4.8TB at 8 bytes per ID. That's spread across a big cache tier, with the source of truth in a sharded database.
The most important design decision here is not about speed. It's that every read path goes through one privacy check. Most real-world privacy bugs are not wrong rules, they're a surface that forgot to apply them: a search result, a notification preview, an API endpoint. Say this early.