Design Find My iPhone
Understanding the Problem
📱 What is Find My iPhone? Find My lets you see where your devices are on a map and act on them: play a sound to find your phone in the couch, mark a lost phone so whoever finds it sees your number, or erase it remotely if it's stolen. It also finds things that have no internet connection at all, like an AirTag on your keys or a laptop that's asleep, by using other people's nearby phones as anonymous relays over Bluetooth. Google's Find My Device and Samsung's SmartThings Find do the same thing.
The question usually comes with a few numbers: the owner should see a fresh location within 30 seconds of asking, the system handles about 1 billion requests a day, and it should work for Bluetooth trackers like AirTags. Online devices (a phone with a data connection) and offline items (an AirTag) are the same product to the user but need very different designs, and the offline one has a strong privacy angle. We'll design the online path first and then the Bluetooth network.
Functional Requirements
Core Requirements
- Devices should be able to report their location to the service, periodically and on demand.
- Owners should be able to see the current location of each of their devices on a map, refreshed within 30 seconds when they ask.
- Owners should be able to send commands to a device: play a sound, enable lost mode, or erase it.
- Owners should be able to locate offline devices and Bluetooth trackers (AirTags) through nearby devices that report what they hear.
Below the line (out of scope)
- Sharing your own location with friends and family (the "People" tab). It reuses much of this, but it's a social feature with its own permissions.
- Precision finding with ultra-wideband (the arrow pointing to the AirTag in the same room). It's on-device radio work.
- Account recovery and activation lock internals.
Non-Functional Requirements
Ask about scale. We'll assume on the order of 2 billion enrolled devices and the stated 1B requests a day for location reports, lookups and commands, plus a separate, larger stream of crowd-sourced Bluetooth sightings.
Core Requirements
- When an owner asks to locate an online device, a fresh location should appear within 30 seconds; the last known location should show immediately.
- The system should handle 1B requests a day, about 12k per second on average and around 40k per second at peak.
- Locations are sensitive: the service should store as little as possible, for as short a time as possible, and for crowd-sourced sightings it should be unable to read the locations at all (end-to-end encryption).
- The device side must be gentle on battery. Reporting can't drain a phone, and helping find other people's AirTags must be nearly free.
- Commands like erase must be delivered reliably, exactly once in effect, and only from the real owner.
Below the line (out of scope)
- Strong consistency for locations. Last-write-wins is fine.
- Long-term location history. We keep hours to days, not years.
Back-of-the-envelope:
- Online requests: 1B a day / 86,400 ≈ 11.6k per second, peak ~40k/s. If most are device location reports at ~200 bytes, that's under 10MB/s of writes. Easy for a sharded key-value store.
- Storage for latest locations: 2B devices × ~200 bytes ≈ 400GB. Fits comfortably in a key-value store, even with replication.
- Crowd sightings: suppose 1B finder phones each upload a batch of sightings every 15-30 minutes when they've heard something. At roughly 10-20 billion sightings a day, that's 100-200k writes per second, each an encrypted blob of ~100 bytes. This is the biggest write stream in the system, and it's write-heavy: most sightings are never read.
The 30-second target is mostly a wake-up problem, not a database problem. The device is asleep, maybe in a basement on a weak connection. Getting it to wake, get a GPS fix and upload within the budget is the real work; storing one row is trivial.