Design Facebook Event Attendance Prediction
Understanding the Problem
📅 What is event attendance prediction? On a social network, people create events: a birthday dinner for 12 invited friends, a neighborhood yard sale, a concert open to everyone. Guests can RSVP "going," "interested" or "can't go," but RSVPs are a weak promise. Event attendance prediction estimates, for a person and an event, the probability that they will actually be there. It powers which events a user is shown, which reminders they get, and the "expect around 40 people" estimate a host sees.
The interviewer will usually stress private vs public events. They behave so differently that they almost look like two problems. A private event has a fixed invite list, strong social ties to the host and high attendance rates; the question is which of 30 invitees show up. A public event can be attended by anyone; the question is which of millions of nearby users might come, which is a recommendation problem with very low base rates. We'll build one system that handles both and be explicit about where they differ.
Functional Requirements
Core Requirements
- For any invited user, the system should predict the probability that they attend an event, for both private and public events, updated as the event approaches.
- For each user, the system should rank upcoming public events by how likely the user is to attend, for the Events tab and notifications.
- For each event, the host should see an expected attendance number with a range, updated as RSVPs change.
- Private events must only ever be scored for and shown to their invitees.
Below the line (out of scope)
- Ticketing and payments.
- Creating events and the invite flow itself.
- Detecting duplicate events (see duplicate event detection).
Non-Functional Requirements
Assumptions to confirm with your interviewer: 500 million monthly users of Events, 20 million upcoming events at any time (about 5 million public), private events averaging 30 invitees, and the Events surface loaded about 50 million times a day (around 600 per second, 2,000 at peak).
Core Requirements
- The Events tab should rank events within 200 ms at p99.
- Host estimates should update within a few minutes of an RSVP change. They don't need to be real time.
- Predictions must be calibrated, because a headcount is a sum of probabilities. A model that ranks well but says 0.6 when the truth is 0.3 doubles the host's estimate.
- Privacy: a host sees an aggregate number, never "Alice probably won't come." Private events never leak outside the invite list, including through features of other users' models.
Below the line (out of scope)
- Real-time location tracking during the event.
- Fine-grained per-country privacy settings, beyond "respect the user's location setting."
A bit of arithmetic. For ranking, say each Events load considers 1,000 candidate events (nearby public events plus invitations). At 2,000 loads per second that's 2 million (user, event) scores per second, which pushes us toward a two-stage design: cheap retrieval, then a heavier ranker on a few hundred. For host estimates, 20 million events with about 50 scored users each is 1 billion pairs; scoring them nightly in batch and incrementally re-scoring the pairs touched by RSVP changes is cheap. The most interesting number is the base rate: an invited guest to a friend's dinner might attend 50% of the time, while a random nearby user shown a public concert attends maybe 0.1% of the time. A single uncalibrated model across both will be wrong for both.
The trap in this question is assuming you know who attended. You mostly don't. Raise it early: "Before choosing a model, let's talk about where the attendance label comes from."