Google Maps API Design
Explore how to design the Google Maps API by understanding its key components, such as map tile delivery, route finding, navigation, and place search. Learn to apply architectural styles, protocols, and data formats to ensure low latency, scalability, and high availability in a real-world API scenario. Gain insights into the integration of REST, WebSockets, and HTTP/2 to support diverse client-server interactions and optimize user experience.
Google Maps API: Requirements and foundations
Google Maps provides travel-critical information: distance, ETA, optimal paths based on traffic, and turn-by-turn directions. Each capability maps to a distinct API surface. Designing these APIs requires understanding the backend system because an API reflects the underlying architecture. The design spans service workflows, endpoint definitions, request-response formats, and latency budgets.
Note: An optimal path is not always the shortest one, but rather the one that considers time, road closures, business needs, and real-world conditions.
Functional requirements
Map: Return map area snapshots based on user location and zoom level.
Route finder: Return optimal path(s) with distance and ETA based on source, destination, and transportation mode.
Navigation: Consume the user's GPS location in real time, guide decisions along the route, and continuously update ETA and distance.
Search place: Find and return information for a searched location or entity.
Nonfunctional requirements
Availability: High availability across all operations.
Accuracy: Optimal route(s) with accurate ETA.
Scalability: Handle large volumes of concurrent user requests.
Low latency: Real-time responses, with stringent requirements for navigation and relaxed tolerances for map tile retrieval.
Prerequisites
Two previously designed APIs serve as building blocks:
Search API: Enables place discovery on the map.
Pub-sub API: Handles inter-service communication (e.g., the navigation service triggers rerouting via pub-sub when a user deviates).
Design overview and decisions
With requirements established, the next step is selecting architectural styles, protocols, and data formats. The high-level architecture divides into three component categories:
Primary services: Client-facing services called via an API gateway that perform core functions: route finding, navigation, place search, and map tile delivery.
Persistence layer: Stores map tiles, road data, and analytics datasets.
Secondary services: Internal services (traffic analysis, data analytics) that support primary services. For example, analytics detects road closures from aggregated user locations and updates the maps service via pub-sub.
Note: Map tiles represent portions of the world map, each with a unique ID. The world map is divided into tiles based on zoom level and served from blob stores or CDNs to avoid transmitting the entire map.
The components and services involved in the Google Maps design are summarized in the following table:
Components and Services Details
Component or Service | Details |
Maps service |
|
Places service |
|
Route finder service |
|
Navigation service |
|
Pub-sub service |
|
Data analytic service |
|
Traffic service |
|
API gateway |
|
Database |
|
Workflow
Four ...