Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Vehicle Overspeed Alert System

Turn a GPS log from every vehicle every 10 seconds into exactly one alert per 2-minute overspeed, notify the fleet's managers, and keep alerts correct when servers crash or logs arrive late or twice.

Problem statement

Design an overspeed alert system for a vehicle tracking product. Each vehicle's GPS device sends a log every 10 seconds with a timestamp, latitude, longitude, speed and vehicle ID.

When a vehicle stays above 90 km/h for 2 minutes, the system alerts the people who track that vehicle, and it must keep working when parts of it fail.

When an alert fires. - For this exercise, assume the speed in each log is in km/h and the timestamp is the time the device took the reading. - Assume a speeding run is a series of one vehicle's logs that are all above 90 km/h, each at most 30 seconds after the one before. One or two lost logs do not break a run. A log at or below 90 km/h, or a silence longer than 30 seconds, ends it. - The alert fires on the first log of the run that is at least 2 minutes after the run's first log. When no logs are lost, that is the run's 13th log. A run gets exactly one alert, however long it lasts.

Who gets it. - Assume every vehicle belongs to one fleet, and each fleet has a few managers. Every manager of the vehicle's fleet gets a push notification or an SMS, as they chose, and the alert also appears in the app. - Managers can list their fleet's alerts for a time range and open one alert to see the GPS points of its run.

How devices send logs. - Assume each device sends its logs in time order. When it loses its connection, it keeps its logs and uploads them oldest first once it is back. A retry can send the same log twice. - Assume late logs still count: the alert is still created, and its notification says when the speeding happened.

Out of scope: fuel and theft alerts, the live map, device hardware and firmware, and how managers sign in.

What to build

  1. Accept every GPS log a device sends, including late and repeated ones, and keep the logs for 90 days.
  2. Create exactly one alert for every run in which a vehicle stays above 90 km/h for 2 minutes.
  3. Build a notification for each alert and send it to every manager of the vehicle's fleet by push or SMS.
  4. Let a manager list the fleet's alerts for a time range and open one alert, including the GPS points of its run.

At scale

  • Each vehicle's device sends one log every 10 seconds with a timestamp, latitude, longitude, speed and vehicle ID.
  • For this exercise, assume 1,000,000 vehicles. Devices send logs only while the vehicle is on: at the daytime peak nearly all of them are on, about 100,000 logs per second, and about 50,000 per second averaged over a day.
  • For this exercise, assume raw logs are kept for 90 days and are read by vehicle and time range, for example to show the points behind an alert.
  • For this exercise, assume that for a vehicle that is online, the notification goes out within 30 seconds after the system receives the log that completes the 2 minutes. No run may be missed and none may be alerted twice, even when a server crashes or a log arrives twice.