Product Context
Meta wants to improve Nearby Friends on Facebook so users can discover which friends are physically close enough to meet, while respecting privacy settings and battery constraints. The feature is shown in the Facebook app and may also trigger lightweight notifications when a highly relevant nearby friend appears.
Scale
| Signal | Value |
|---|
| Facebook DAU eligible for location sharing | 120M |
| Concurrent mobile users with fresh location | 18M |
| Peak location update QPS | 900K updates/sec |
| Peak read QPS for Nearby Friends requests | 250K requests/sec |
| Average friend graph size | 350 friends/user |
| 95th percentile friend graph size | 2,500 friends/user |
| Candidate pool before ranking | 10-500 friends/request |
| End-to-end p99 latency budget | 150ms |
Task
Design an end-to-end ML system for Nearby Friends. Your design should address:
- How to define the product objective, labels, and success metrics for surfacing nearby friends or sending notifications
- How to size the system and design the online architecture from location ingestion to retrieval, ranking, and re-ranking
- What models you would use at each stage, and which features should be computed online vs batch
- How to handle privacy controls, cold start, sparse labels, and rapidly changing context like movement or venue changes
- How to evaluate the system offline and online, including guardrails for privacy, battery, and notification fatigue
- What failure modes you expect at Meta scale, and how you would detect and mitigate them
Constraints
- Users must explicitly opt in to location sharing; privacy settings may restrict visibility to subsets of friends
- Raw GPS traces have limited retention and must be minimized in training data
- Location and movement features are highly dynamic; stale predictions are often worse than no prediction
- Mobile battery and network usage are first-class constraints
- The system should support both in-app ranking and optional notification triggering without spamming users