Design a Centralized Log Ingestion and Search Platform
Design a multi-tenant platform that durably ingests structured logs and provides coherent recent-event search and exact keyword occurrence counts.
Problem statement
Design a central logging platform that many tenants share. Application services send it structured log events, and authorized operators search them. Each tenant sees only its own logs.
Log events. Each event has a tenant ID, environment, service, a stable event ID, the time it happened at the source, a severity, a message, and a limited set of key-value attributes. Producers send events in batches of limited size, with a stable request ID for each batch and a stable ID for each event.
Ingestion. An accepted batch must survive the loss of one zone. Producer retries and consumer replays inside the pipeline must not create extra searchable events. Ingestion is asynchronous, so an accepted event becomes searchable a little later. Don't imply search is complete right away. Instead, show how far ingestion and indexing have got. A partition's search watermark is the point up to which that partition is searchable. A quarantined record is one set aside because it could not be processed.
Search. An operator searches within one tenant and one environment over a limited time range. They can match message text and filter by service, severity and exact values of approved attributes. Results are sorted newest first by source time, then by event ID. Paging through results stays consistent with the first page. Each search response says whether it is complete, partial-coverage or unavailable.
Keyword counts. An operator can also get exact counts for 1 to 20 different keywords, within the same tenant, environment, approved filters and limited source-time range. A keyword is one token of ASCII letters and digits, at most 64 characters long. To match, split each message into the longest runs of ASCII letters and digits and compare them in lowercase. Count every occurrence, including repeats inside one event. Return every requested keyword with its whole-number count, including zero. A count covers the accepted events visible in one declared search snapshot and its partition watermarks, so a retry or replay never counts twice. A late event appears only in snapshots published after it is indexed; an earlier snapshot never changes. A count response uses the same complete, partial-coverage or unavailable status as search and says which partitions and watermark it covers. Never report an incomplete count as complete. Phrases, stemming, ranking and approximate counts are out of scope.
Isolation and overload. Give each tenant explicit quotas. Stay correct under overload and replay. Under overload, throttle explicitly or return a partial-coverage response.
Out of scope: metrics, traces, alerting, anomaly detection, security-event correlation (SIEM), arbitrary joins, and searches across all tenants or over unlimited history.
What to build
- A producer can durably send a limited-size batch of log events, and a retried batch ends in the same single accepted result.
- An operator can search one tenant and environment over a limited time range by text and approved filters, in a stable order with consistent paging. The operator can also get exact per-keyword counts for a declared snapshot.
- Producers and operators can see durable ingest positions, search watermarks, missing partition coverage and quarantined events.
- The platform keeps accepted events for the full retention period and recovers ingestion and indexing after failures without losing events, showing duplicates or leaving silent gaps.
At scale
- Peak: 2 million accepted events per second, about 2 KB each on average.
- 10,000 queries per second, searches and keyword counts combined.
- 99% of accepted events are searchable within 30 seconds.
- A common recent-log query, search or keyword count, returns within 1 second at p95.
- Keep events searchable for 30 days. Accept events whose source time is up to 24 hours late.