Strava Fitness Tracking
GPS activity and social fitness platform
Design a fitness app that records GPS activities, computes their stats, matches them against community-drawn segments with leaderboards, and shares them with followers without exposing where people live.
Overview
A fitness tracking app records a run or ride as a GPS track: a point every second or so with latitude, longitude, altitude and time, often with heart rate. After the upload, the service computes distance, pace and elevation gain, finds every segment the activity covered (a stretch of road or trail that athletes race on, drawn by the community), ranks the effort on each segment's leaderboard, and posts the activity to followers' feeds.
The work is almost all after the upload, so the design is an asynchronous pipeline. The two parts interviewers probe are segment matching (a geospatial search, then a careful path comparison) and leaderboards (a rank query on tables with millions of rows). Privacy runs through everything: a GPS track that starts at someone's front door says where they live.
Questions to ask first
- How many activities? — 5 million uploads a day; a typical activity is 1 hour at 1 point a second
- How fast must results appear? — Stats and segments within about 30 seconds of upload
- How many segments? — Tens of millions, each a polyline of up to a few kilometers
- Leaderboards? — Per segment, best time per athlete; filters by gender, age, people you follow
- Live tracking? — Out of scope; uploads happen after the activity
- Privacy? — Hide the start and end of every map by default; per-activity visibility
What you will be able to do
- Design an upload path that acknowledges fast and processes in the background.
- Compute distance and elevation from noisy GPS data.
- Match an activity against millions of segments with a spatial index.
- Answer rank queries on huge leaderboards in sub-linear time.
- Apply map privacy before anything leaves the owner's account.
Key concepts
- Async processing pipeline
- GPS cleanup
- Haversine distance
- Spatial index
- Segment matching
- Leaderboards
- Rank cache
- Privacy zones
- Fan-out on write
Functional requirements
- Upload a recorded activity file (GPS points, times, heart rate)
- Show distance, moving time, pace or speed and elevation gain
- Find every segment the activity covered and record an effort with its time
- Show segment leaderboards (overall, by gender and age, people you follow) and your rank
- Show followed athletes' activities in a feed
- Hide the start and end of maps, or whole maps, and set each activity's visibility
Non-functional requirements
- An upload is acknowledged in under 1 second (a target we chose)
- Stats and segment efforts appear within 30 seconds at p99 (a target we chose)
- A leaderboard page and a rank lookup return in under 250 ms at p99 (a target we chose)
- No uploaded activity is lost, even if processing fails
- Hidden parts of a map are never served to other users
Interview questions
- Why is the upload asynchronous, and what does the client see?
- How do you match an activity against tens of millions of segments?
- How do you answer a rank query on a leaderboard with a million athletes?
- Why not just use Redis sorted sets for leaderboards?
- How do you keep someone's home address private?
- How do you compute elevation gain from GPS?
- What happens on the first Saturday of the month?
Sign up free to read the full topic
More System Design topics
- SQL Isolation Levels Deep Dive
- SQL vs NoSQL Trade-offs
- Stateful vs Stateless Services
- Sticky Sessions
- Stock Exchange
- Stock Trading App (Robinhood)
- Strong vs Eventual Consistency
- Subscription Commerce Platform
- Supply Chain Visibility and Tracking
- Synchronous vs Asynchronous Communication
- Synthetic Data Generation System
- Text Summarization System
Start free on Cariara · Coding problems · System design studio