🎓 A1Learner
🔍
0 of 64 lessons completed

Design Strava

Strava is an activity service that records runs and rides as GPS tracks, stores them and compares them on shared segments. Phones record offline for hours, and the upload arrives as one large burst.

The ask

An athlete records a run or a ride with a phone or a watch. The track shows the route, pace, climb and time.

A segment is a named stretch of road or trail. Every effort over a segment earns a place on its leaderboard.

Friends see activities in a feed and give praise or comments. Clubs gather activities by place and sport.

Privacy is a first-order need. A home address hides inside the start of many tracks.

Estimate the scale

Activities arrive at 10,000,000 a day.

10,000,000 activities / 86,400 seconds = 116 activities per second.

One activity records one GPS point per second for an hour. That shape gives 3,600 points in one activity.

10,000,000 activities x 3,600 points = 36,000,000,000 points a day.

One point takes 16 bytes. The points fill 576,000,000,000 bytes a day, which is 576 GB of points a day.

Arrivals bunch at morning and evening peaks. Upload bursts, not the average rate, size the intake side.

API and data

The upload operation takes an athlete, a sport and the full point list. It returns an activity and its processing state.

The feed operation takes an athlete. It returns recent activities from followed athletes and clubs.

The segment operation takes a segment. It returns its leaderboard and the asker's own best effort.

An activity holds an athlete, a sport, a start time and summary values. Summaries cover distance, time, climb and average pace.

Points live apart from the activity summary. A point holds a time, coordinates and a height, stored in time order.

High-level design

Phones and watches record locally and upload whole tracks. An intake service accepts uploads and stores raw points in blob storage.

A queue carries each new activity to processing workers. Workers compute summaries and clean bad points.

A segment matcher compares the track against segments in its area. Matches create efforts, and efforts feed leaderboards.

Feed entries are written when processing finishes. Friends read a ready feed instead of a live computation.

Raw tracks stay immutable. Every summary and effort can be rebuilt from the raw points.

Deep dive: segment matching

A track crosses thousands of known segments. Checking every segment against every track wastes the fleet.

Segments are indexed by place with a geospatial index. Only segments whose area the track enters get checked.

GPS points wobble around the true path. Matching allows a small distance from the segment line at each point.

An effort needs the whole segment in order, without a long stop inside it. Partial crossings create no effort.

Leaderboards update from efforts, not from raw uploads. One bad upload can be removed and its efforts rebuilt.

Deep dive: privacy zones

A privacy zone hides the part of a track inside a chosen area. Athletes set zones around home and work.

Hiding happens before any other processing reads the track. Segment matching and feeds see the trimmed track only.

The raw track stays private to the owner. Public views, maps and shared links all use the trimmed form.

A zone added later re-trims older activities. Stored public copies are rebuilt, not just hidden on screen.

When GPS data is bad

A tunnel drops points, and a city centre bounces them between buildings. Raw tracks carry spikes and gaps.

Processing removes points that imply an impossible speed for the sport. The gap stays marked as a gap.

Distance comes from cleaned points. Pace over a gap is shown as paused or estimated, never as a sudden sprint.

A car journey recorded as a ride breaks leaderboards. Speed patterns flag it, and the athlete or a reviewer removes it.

Evaluation and trade-offs

Whole-track upload fits offline sport. The price is delayed feeds and leaderboards that settle after processing.

Immutable raw points make every derived value rebuildable. Storage grows daily, and summaries carry almost all reads.

Segments turn private exercise into shared competition. Strava scales because matching stays local to the track's own area.

Privacy trimming runs before everything else. A fast leaderboard is worth nothing if a home address leaks.

Scale at a glance

MeasureFigure
Activities a day10,000,000
Activities per second116
GPS points in one activity3,600
GPS points a day36,000,000,000
Point data a day576 GB

Exercise

A phone finishes a long ride with no signal during the ride. What does the design do?