Data & analytics
Log aggregation - the index is bigger than the data
Why searching your logs costs thirteen times more than keeping them, and what you can no longer ask once you sample.
The first act plays here. Owned once with credits, never a subscription.
What this board gets wrong on purpose
The tension
THE SAMPLER IS THE BEST LEVER IN THE SYSTEM AND IT IS IRREVERSIBLE. Dropping ninety percent of successful requests cuts the bill by eighty-five percent and silently removes the ability to answer "what happened to THIS request" - there is no error, no gap in the UI, and the question simply returns nothing, which is indistinguishable from the request never happening. The second unresolved thing is that log volume rises five to twenty times during an incident, which is exactly when somebody is typing a query, so the indexer is furthest behind at the moment freshness matters most and the honest options are all bad: shed load and lose the incident's own logs, buffer and be minutes stale, or provision twenty times the steady-state indexing fleet and pay for it every quiet day of the year. And the retention policy is written as a cost decision but is enforced as a legal one - a legal hold on a tenant that has already had its shards deleted is a problem no amount of engineering fixes afterwards.
Practise this as an interview
Take Log aggregation - the index is bigger than the data as a timed system design interview on a blank board - on your own, with the requirements to check yourself against, or with a candidate you invite.
Start here
Why this design
Log aggregation looks like plumbing and is really a cost-model question. Interviewers use it to see whether you can separate the copy you keep to SEARCH from the copy you keep to READ, size a pipeline for the incident rather than the average day, and say plainly what sampling destroys. Platform teams care because the log bill is routinely one of the largest lines in an infrastructure budget, and because a log pipeline tends to fall behind during exactly the outage it exists to explain.
What you will learn
- Why a 400 B line costs about 520 B fully indexed and 40 B archived - the 13 : 1 ratio every other decision on the board follows from.
- Sizing from the fleet: 3,000 instances x 50 lines/s = 13 billion lines and 5.2 TB a day, with 5x to 20x spikes during an incident.
- How a 2 GB node buffer and a 24-hour, 48-partition transport queue turn a downstream outage into delay rather than loss - and why backpressure must never reach the application.
- What sampling all errors and 1 in 10 successes, per trace, saves (11.8% kept) and which questions it makes permanently unanswerable.
- Why "drop the index, keep the bytes" at 7 days turns 2.4 PB a year into 195 TB and a 187x cost difference.
- Why search must report the indexing watermark and the shards that did not answer, instead of presenting partial results as complete.
How to read this board
- Press play once: nine steps follow one line from stdout to an engineer's query at three in the morning.
- PRODUCE, then COLLECT: structured JSON to stdout, enrichment at the node agent, and the red sampler - the cheapest lever and the only box that destroys evidence.
- SHIP · THE BUFFER THAT ABSORBS AN INCIDENT: the disk buffer, the transport queue, and the parser that turns one line into three copies.
- INDEX · BIGGER THAN THE DATA IT INDEXES: follow the expensive copy into the inverted index and hot shards, and the cheap one into the cold archive; then rollover drops the index and keeps the bytes.
- SEARCH · AT THREE IN THE MORNING: scatter-gather over shards, the stale-index watermark, and log-based alerts.
- Pages 1 to 6 in order: requirements, capacity, storage, availability, how it works, deployment.
- DATA MODEL: sources, the shape of a line, shards, sampling rules and retention policies - the metadata that decides which lines exist at all.
1 · Requirements
Ask these before drawing anything
- What question are the logs for? Debugging one request, auditing who did what, and counting how often something happens are three different systems. The third one should be a metric and using logs for it is the most expensive mistake in this category.
- How long must a line be searchable, and how long must it merely EXIST? These are different numbers with a thirteen-to-one cost ratio between them, and treating them as one number is how a log bill becomes the largest line item in an infrastructure budget.
- Is any of this subject to audit or legal hold? If yes, deletion stops being a cost optimisation and becomes a compliance operation, with an approval and a record.
- Do logs contain personal data or secrets? They do. Everyone says no and everyone is wrong - a request body logged on error, a token in a URL, an email in a stack trace. Whether redaction happens at the agent or never happens is decided here.
- How much does volume rise during an incident? Nobody measures this until the first time the log system falls over during an outage. Five to twenty times is the usual answer.
- Who pays? If it is a central platform budget, every team logs everything. If it is charged back per team, volume drops by half in a month without a single engineering change.
Functional
- Collect from every process on every node without the application knowing how, and without a slow collector ever blocking the application.
- Enrich every line with its service, pod, region, deploy version and trace id at collection time - not at query time, when the pod that produced it no longer exists.
- Make a line searchable within 10 seconds of it being written, at p95.
- Full-text search plus structured field filters over any time range within the hot window.
- Keep an unindexed, compressed copy of EVERY line - including sampled-out ones where the policy allows - for one year, retrievable by time and source.
- Apply sampling and drop rules centrally, with a record of what was dropped and by which rule.
- Evaluate saved queries as alerts every 60 seconds.
Non-functional
- Ingest must never block a producing application. The agent writes to local disk and a full disk drops lines rather than applying backpressure into the process - a logging system that can stall a production service is worse than no logging system.
- Search p95 under 3 seconds over a 24 hour window; under 30 seconds over the full hot window.
- Survive a 20x volume spike for 30 minutes without losing a line. This is the requirement that sizes the transport queue and the node buffer, and it is the one that gets cut first and regretted first.
- Tenant isolation on every query: one team must not read another team's logs, and the filter is applied by the search API, never by the UI.
- Cost per GB ingested is a published number that teams can see against their own volume.
Out of scope
- Metrics. Counting things with a log query works until it costs a hundred times what a counter would and is a hundred times slower.
- Distributed tracing. The trace id is carried here so the two systems can be joined, but spans belong somewhere built for them.
- Long-term analytics over logs. A year of archive is for answering a specific question about a specific past moment, not for a quarterly report.
The rest of this board
Available on Tier Slate
This page publishes the question. The answer — 5 more written pages, a 9-step narrated walkthrough and a 5-table schema — is the board itself, and it opens in Tierslate.
- 5written pages
- 9walkthrough steps
- 5tables42 columns
5 pages behind this one
- Capacity estimation
- Storage estimation
- Availability
- How it works
- Deployment plan