Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

Your self-hosted ELK cluster ingests 5 TB of logs per day, is costly and unstable at peaks. Design changes to make centralized logging sustainable.

Start by reducing volume at the source: sensible log levels, sampling of noisy logs, dropping health check logs and moving metric-like logs to real metrics. Put a buffer such as Kafka between the shippers and Elasticsearch so peaks queue instead of overloading the cluster, and use index lifecycle management with data streams and hot, warm and cold tiers, with short retention for debug logs. Then compare managed offerings and alternatives such as OpenSearch, Loki or cloud logging on query needs and cost, and check licensing, since Elasticsearch left Apache 2.0 in 2021 and added AGPL as an option in 2024.

Why this question is asked

A self-hosted logging cluster that ingests 5 TB a day is a serious production system, and when it is unstable at peaks it fails exactly when we need it most: during incidents, when every service logs errors at once. When it is costly, the cost usually comes from storing too much on expensive hardware for too long. Interviewers ask this design question to see whether we can attack the problem in the right order, volume first, then architecture, then platform choice, with numbers. In this answer, we will size the problem, cut volume at the source, add a buffer for peaks, design storage tiers with lifecycle rules, consider alternatives, and note the licensing question.

1Sizing the Problem

Numbers make the options clear. 5 TB a day is about 58 MB per second on average, and log traffic is not flat: daytime peaks and incidents can reach three to five times the average, so the cluster must absorb around 200 to 300 MB per second at the worst moments. With one replica for resilience, every byte is stored twice. If all logs are kept 30 days on hot nodes, that is in the order of 300 TB of fast storage, before compression savings, on nodes that also have to index at peak rates.

Instability at peaks usually means indexing cannot keep up: write queues fill, shippers retry, nodes run out of heap, and searches time out. Cost usually means too much data on hot nodes for too long. Both point to the same levers.

2Reduce Volume at the Source

The cheapest byte is the one we never ship. We rank sources by volume and by how often they are searched; in clusters like this, a handful of sources commonly produce more than half the volume. Typical fixes: production runs at INFO, with DEBUG turned on temporarily through Actuator's loggers endpoint during an investigation; access logs for health checks and readiness probes are dropped at the shipper; very repetitive success lines, such as one line per Kafka message processed, are sampled at 1 to 10 percent while every warning and error is kept; and lines that exist only to be counted are replaced by Micrometer counters, which cost almost nothing.

These changes often remove 30 to 50 percent of the volume. Each one is small, but together they shrink every later cost: fewer nodes, less storage, smaller peaks. They also improve search, because engineers no longer wade through noise.

Java
# Fluent Bit: drop health checks before they leave the node
[FILTER]
Name grep
Match kube.*
Exclude path ^/actuator/health
# Spring Boot: counter instead of a log line per processed message
registry.counter("orders.consumed", "topic", topic).increment(); // one series, not millions of lines

3Buffer Peaks With Kafka

Today shippers send directly to Elasticsearch, so when a peak exceeds indexing capacity, back pressure reaches the shippers, they retry and buffer on nodes, and the cluster is hit even harder when it is already struggling. Putting Kafka in between changes the shape of the problem. Shippers write to Kafka, which is built to accept bursts at high rates and keeps data for a configured retention, for example 48 hours. A group of Logstash or other consumers reads from Kafka and indexes at the rate the cluster can sustain.

During a peak, consumer lag grows instead of the cluster falling over; when the peak passes, consumers catch up. Logs appear in Kibana a few minutes late during the worst moments, which is an acceptable trade for not losing them. Kafka also lets us replay data after an indexing bug, and feed the same logs to a second destination such as a security tool or a new backend under evaluation.

Step throughLogging pipeline with a buffer
  1. ServicesJSON to stdout, levels and sampling applied
  2. Node shippersFluent Bit or Filebeat; drop noise, add k8s metadata
  3. KafkaTopics per log class, 48 h retention, absorbs peaks
  4. IndexersLogstash or consumers, scaled to sustainable rate
  5. Elasticsearch tiersHot, warm, cold via ILM and data streams
  6. KibanaSearch, dashboards, alerts

6 layers, from the top down. Step through them one at a time.

Kafka turns overload into lag that clears after the peak.

4Storage Tiers and Lifecycle Rules

Most searches hit the last day or two; older logs are read rarely. Index lifecycle management, ILM, moves data through tiers automatically. Data streams give each log class a single name to write to, with backing indices that roll over by size or age. Hot nodes with fast disks hold the newest data and do all the indexing. After a few days, indices move to warm nodes with cheaper, larger disks and fewer replicas, and later to cold storage, which can use searchable snapshots on object storage; some of these features need a paid Elastic subscription, so check what your licence includes.

Retention follows the log class. Debug and operations logs might live 3 days hot, 4 days warm and then be deleted, 7 days in total. Logs needed for longer investigations stay 30 days, mostly on warm and cold. Audit and security logs go to separate data streams with their own longer policy. With most data on cheaper tiers and debug logs short-lived, hot storage drops from hundreds of terabytes to a few tens.

Java
PUT _ilm/policy/logs-debug
{
"policy": {
"phases": {
"hot": { "actions": { "rollover": { "max_primary_shard_size": "50gb", "max_age": "1d" } } },
"warm": { "min_age": "3d", "actions": { "shrink": { "number_of_shards": 1 }, "forcemerge": { "max_num_segments": 1 } } },
"delete": { "min_age": "7d", "actions": { "delete": {} } }
}
}
}

Rolling over by primary shard size keeps shards in a healthy range of tens of gigabytes, instead of thousands of tiny daily shards that waste heap, which is itself a common cause of instability.

5Considering Managed Offerings and Alternatives

Once volume and architecture are fixed, we can compare platforms fairly. A managed Elasticsearch or OpenSearch service removes cluster operations but usually costs more per gigabyte. OpenSearch, the fork of Elasticsearch 7.10 maintained under an open-source foundation, is close in features and keeps an Apache 2.0 licence. Grafana Loki indexes only labels and stores compressed log chunks in object storage, which is much cheaper for large volumes, at the cost of slower full-text search across long periods. Cloud providers' logging services are simple to adopt but can become expensive at this volume and tie us to one cloud.

The choice depends on how logs are queried. If engineers mostly filter by service and trace id over recent data, Loki-style storage can cut costs dramatically. If security teams run complex full-text searches over months, an Elasticsearch-style index earns its cost. Many companies end up with a split by log class.

Platform options at 5 TB per day
OptionStrengthWatch out for
Self-hosted Elasticsearch, tunedFull-text search, team knows itOperations effort, licence terms
Managed Elasticsearch or OpenSearchNo cluster operationsHigher price per GB
Self-hosted OpenSearchApache 2.0, similar featuresMigration, operations effort
Grafana LokiCheap object storage at volumeSlower broad full-text search
Cloud provider loggingEasy start, integratedCost at volume, cloud lock-in

6A Note on Licensing

Licensing affects the long-term choice. In 2021 Elastic moved Elasticsearch and Kibana from the Apache 2.0 licence to a choice of the Server Side Public License and the Elastic License; that change is what led to the OpenSearch fork. In 2024 Elastic added AGPLv3 as a further option. For an internal logging cluster, most companies can use the free tier, but features such as some security, cold and frozen tiers and machine learning depend on the subscription level, and offering Elasticsearch as a service to others has specific restrictions. These terms change, so check the current licence and subscription matrix with legal before deciding.

7Follow-up questions

How many Kafka partitions and consumers do we need?

Enough partitions that consumers can index the peak rate when needed, and enough consumers to drain the lag within an acceptable time after a peak. As a starting point, measure how many MB per second one indexer sustains, divide the target catch-up rate by that, and give the topic at least that many partitions with room to grow.

What about sampling errors to save cost?

Errors and warnings should not be sampled; they are the logs we need in incidents and usually a small share of volume. Sampling is for high-volume, repetitive success lines, where keeping one in ten loses very little information.

8Conclusion

In this answer, we made a 5 TB per day logging platform sustainable. We sized the problem, about 58 MB per second on average and several times that at peaks, then cut volume at the source with levels, sampling, dropped health checks and metrics instead of counting logs. Kafka between shippers and Elasticsearch turns peaks into lag rather than outages, and ILM with data streams and hot, warm and cold tiers keeps most data on cheaper storage, with short retention for debug logs. Finally, we compared managed services, OpenSearch, Loki and cloud logging by query needs and cost, and checked Elasticsearch's licence terms.

What to say in the interviewAbout 90 seconds aloud

Open with

I'd attack it in order: volume, then architecture, then platform. Five terabytes a day is about 58 megabytes a second on average and several times that at peaks, stored twice with a replica, so I'd first rank log sources by volume and by how often they're searched.

Then, if they want more

Running production at INFO, dropping health check logs at the shipper, sampling repetitive success lines while keeping every warning and error, and turning counting logs into Micrometer counters typically removes thirty to fifty percent.

Then I'd fix peaks with a buffer: shippers write to Kafka with a day or two of retention, and indexers consume at a rate the cluster can sustain, so a peak becomes consumer lag instead of a cluster falling over, and we can replay.

For cost, I'd use data streams with ILM: hot nodes only for the first few days, rollover by shard size around fifty gigabytes, then warm and cold tiers, and short retention for debug logs, like seven days, with audit and security logs in their own streams.

With that done, I'd compare a managed Elasticsearch or OpenSearch, self-hosted OpenSearch, Loki, which is much cheaper for label and trace id queries, and cloud logging, based on how we actually query. And I'd check licensing: Elastic moved off Apache 2.0 in 2021 and added AGPL in 2024, and some tiers need a subscription.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your self-hosted ELK cluster ingests 5 TB of logs per day, is costly and unstable at...": https://scrivio-interview-library.netlify.app/spring-boot/observability/6f134d8af7/