System Design: Searchable Short-Form Status Updates with Nearby Search
Context
Design a microblogging service where users post short text updates (think: "statuses"). Users must be able to search:
-
Full-text across historical posts (e.g., keyword search, filters by time/language).
-
Geolocation-based "nearby" results (e.g., find posts within a radius from a location, sorted by distance and/or recency).
Assume internet-scale usage with high read and write throughput and global users.
Requirements
-
Functional
-
Users can create, edit, and delete short text posts (e.g., up to 280 characters), optionally with a location (lat, lon).
-
Public search: keyword queries across all public posts; filters for time range, language, and presence of geolocation.
-
Nearby search: given (lat, lon) and radius, return relevant posts near that location, supporting sort by distance and/or recency.
-
Respect privacy/visibility (e.g., public vs restricted); search should only show authorized content.
-
Non-Functional
-
Low latency: p50 < 200 ms, p95 < 500 ms for typical searches; writes < 150 ms.
-
Freshness: new posts searchable within seconds (near real-time indexing).
-
High availability and horizontal scalability; multi-region read latency optimization.
-
Cost-effective historical search (tiered storage for older data).
What to Design
-
High-level architecture (write path, index pipeline, search path).
-
Data model and storage choices for posts and indexes.
-
Full-text indexing and query processing (tokenization, ranking, pagination).
-
Geolocation indexing and query execution for nearby search.
-
Scaling/sharding strategies, caching, and consistency/freshness trade-offs.
-
Handling edits/deletes, privacy filtering, and operational considerations (monitoring, reindexing).