Skip to content

Tune an ELK pipeline for throughput

Speed up a Filebeat, Logstash and Elasticsearch pipeline that is falling behind. You will learn which queue, batch and refresh settings to change, what values to start from and how to confirm the throughput gain.

This article is for operators running an ELK pipeline, where Filebeat ships logs to Logstash and Logstash indexes them into Elasticsearch, that can no longer keep up with the logs coming in. The default settings are deliberately cautious. A pipeline that was fine at launch starts to lag as log volume grows, and the bottleneck moves from one component to the next. Fixing it comes down to a handful of settings. You will raise the queue sizes in Filebeat and Logstash so bursts have somewhere to wait, increase the Logstash batch size and worker count so Elasticsearch receives fewer, larger writes, and relax the Elasticsearch refresh interval so indexing stops competing with search. Each section gives a concrete starting value and explains why it helps, so you tune with evidence instead of guesswork.

How to verify

Confirm whether the pipeline is keeping up before changing anything:

curl -sk -u elastic:"$PW" 'https://es:9200/_nodes/stats/indexing,thread_pool?filter_path=**.indexing.index_total,**.thread_pool.write.queue,**.thread_pool.write.rejected' | jq
curl -s 'http://logstash:9600/_node/stats/pipelines?pretty' | jq '.pipelines.main.events'
curl -s 'http://logstash:9600/_node/stats/jvm' | jq '.jvm.mem.heap_used_percent'
journalctl -u filebeat -n 50 --no-pager | grep -E 'harvester|publish'

If thread_pool.write.rejected is non-zero, Elasticsearch is saturated. If Logstash events.in >> events.out, the bottleneck is downstream. If Filebeat reports “Failed to publish events”, check Logstash backpressure.

What’s happening

The pipeline has three queues and they backpressure each other:

  1. Filebeat output spooler — files are tailed, events are bundled, output is published in batches. The spooler is small (in-memory by default).
  2. Logstash persistent queue (PQ) — events received from beats land in the PQ on disk, workers pull from PQ, filter, and ship to Elasticsearch.
  3. Elasticsearch indexing pressure — bulk requests pile up in the write thread pool. When queue fills, requests are rejected.

The biggest mistake is treating Logstash and Elasticsearch independently. They are paired: Logstash bulk size must match what Elasticsearch can absorb without rejection, and the number of Logstash workers must produce parallelism that stays under indexing pressure.

A second key concept is refresh interval. Elasticsearch refreshes the index every second by default, making new docs searchable. For log ingestion at scale, this is expensive — pushing refresh to 30s on log indices can yield 30-50% indexing throughput improvement.

The procedure

1. Enable Logstash persistent queues. Edit /etc/logstash/logstash.yml:

queue.type: persisted
queue.max_bytes: 8gb
queue.checkpoint.writes: 1024
path.queue: /var/lib/logstash/queue

Persistent queues survive restarts and provide back-pressure to Filebeat instead of dropping events.

2. Set pipeline workers and batch size. In /etc/logstash/pipelines.yml:

- pipeline.id: main
  path.config: /etc/logstash/conf.d/*.conf
  pipeline.workers: 8
  pipeline.batch.size: 500
  pipeline.batch.delay: 50

Rule of thumb: pipeline.workers = number of CPU cores. pipeline.batch.size is 125 by default — bump to 500 (or 1000 for high throughput) so each bulk request to Elasticsearch is meaningful.

3. Configure the Elasticsearch output. In your Logstash output config:

output {
  elasticsearch {
    hosts => ["https://es1:9200","https://es2:9200","https://es3:9200"]
    user  => "logstash_writer"
    password => "${ES_PASS}"
    ssl_certificate_verification => true
    ilm_enabled => true
    ilm_rollover_alias => "logs"
    ilm_policy => "logs-policy"
    document_type => "_doc"
    pipeline => "geoip-enrichment"
  }
}

The same number of bulk threads is implied per host — match this to Elasticsearch’s write thread pool size (processors by default).

4. Tune Elasticsearch indexing. Set per-index settings on hot log indices:

curl -sk -X PUT -u elastic:"$PW" 'https://es:9200/logs-*/_settings' \
  -H 'Content-Type: application/json' \
  -d '{
    "index": {
      "refresh_interval": "30s",
      "number_of_replicas": 1,
      "translog.durability": "async",
      "translog.sync_interval": "30s"
    }
  }'

refresh_interval: 30s cuts segment churn dramatically. translog.durability: async trades a small window of write durability for higher throughput — acceptable for logs because the upstream Filebeat keeps the file as a replay source.

5. Use index templates for new indices. Push these settings into a template (see Elasticsearch index templates) so rolled-over indices inherit the tuning automatically.

6. Cap indexing pressure. Add to elasticsearch.yml:

indexing_pressure.memory.limit: 15%

This caps the in-flight bulk memory at 15% of the JVM heap. When breached, Elasticsearch rejects requests cleanly instead of OOM’ing.

7. Tune Filebeat. In /etc/filebeat/filebeat.yml:

queue.mem:
  events: 4096
  flush.min_events: 2048
  flush.timeout: 1s

output.logstash:
  hosts: ["logstash1:5044","logstash2:5044"]
  loadbalance: true
  worker: 2
  bulk_max_size: 2048
  compression_level: 3

bulk_max_size: 2048 lines up with the Logstash batch you set. compression_level: 3 halves wire bytes with minor CPU cost.

Common pitfalls

  • queue.type: memory in production — events lost on Logstash restart. Always persistent.
  • Cranking workers without raising batch size — each tiny bulk request hits Elasticsearch overhead. Match workers + batch.
  • Forgetting translog.durability for non-log workloads — if you tune logs settings globally, you weaken durability for indices that need it (e.g., business records).
  • Refresh interval of 1s on cold indices — wasted CPU. Use ILM to drop refresh on warm/cold phases.
  • Single Logstash instance — it’s a bottleneck and a SPOF. Run two minimum, with the Beats output loadbalance: true.

In the engagements we run, ELK pipelines fall behind in predictable ways: refresh interval left at 1s, single Logstash worker, no persistent queue, replicas on hot indices. The fixes above are the first pass — beyond that, sharding strategy and ILM tier sizing dominate. See /en/services/managed-operations/ for how we operate logging pipelines as part of the platform.