Facebook Post Search System Design (Indexing & Query at Scale)
Scenario
Users search posts they can see—by keywords, author, time—with latency and freshness expectations that don’t forgive naive “grep the database.” The hard part is inverted index scale plus authorization: two posts might match text, but only one is visible to the searcher. Weak answers index everything and filter later without counting cost.
Design a search service for social posts (Facebook-style): users type a query and see relevant posts from their network and public content they are allowed to view.
Constraints
Keyword search; filter by author, date range, post type (text, link, photo); pagination; respect privacy (friends-only posts invisible to non-friends); hide blocked users
p95 search latency under a few hundred ms for typical queries; high read QPS; index updates visible within seconds to minutes (state target)
Billions of posts; hundreds of millions of searches per day; long tail of rare queries