Design a near-real-time weather API
HubSpotSoftware Engineer · OnsiteLast updated
A HubSpot onsite system-design question: build a weather data platform that ingests hourly dumps for ~2,000 U.S. locations and serves the current temperature with an at-most-10-minute freshness SLA. It tests ingestion pipelines, idempotent retries and backfill, caching and invalidation, storage modeling, rate-limit handling, scaling, and observability on freshness SLOs.
Question
Design a weather data platform that retrieves best-effort hourly dumps from an external Weather Service API for approximately 2,000 locations across the U.S. and exposes an API to return the current temperature for a requested location.
Hard requirement: data served must be at most 10 minutes stale relative to the provider's hourly publish time.
The system should:
- Define a high-level architecture: ingestion, storage, cache, read API, and scheduler/orchestrator.
- Design the API contract: e.g.
GET /temperature?locationId=...(and optionallylat,lon), the response schema, error cases, freshness metadata, and versioning. Support lookup by internalidand by nearest covered location forlat,lon. - Choose a data model and storage (including the location schema, TTL/retention, indexing, and partitioning strategy).
- Specify the ingestion pipeline: detecting a new provider publish, fan-out, retries with backoff, idempotent ingestion, deduplication, and backfill of missed hours, while respecting provider rate limits.
- Lay out the caching and invalidation plan (TTLs, write-through, event-driven invalidation, optional CDN) that meets the 10-minute freshness SLA, plus the API-side freshness gate.
- Cover scaling and partitioning for traffic spikes, and provide rough QPS and storage estimates.
- Describe deployment, cost, and security considerations.
- Describe the test and observability strategy: monitoring/alerting on freshness SLOs, failure handling for upstream slowness / partial failures / outages, and graceful degradation.
- Discuss multi-region availability and disaster recovery (RPO/RTO).
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.