Skip to content

Lesson 3 of 9 · 24m

Indexing Behavior: Refresh, Flush, Translog, and Ingest Throughput

Understand near-real-time visibility, segment creation, bulk indexing, backpressure, and why write-heavy clusters need different treatment than read-heavy ones.

The phrase 'near real time' sounds harmless until someone indexes a document, immediately searches for it, and files a bug because it is missing. Search visibility is controlled by refresh, durability is controlled by translog and flush, and throughput is shaped by segments, bulk sizes, mappings, and cluster contention. Operators who confuse those layers make bad tuning decisions.

Refresh controls search visibility

Newly indexed documents are written to the translog and become searchable after a refresh creates a new searchable segment. The default refresh interval is usually one second:

{
  "settings": {
    "index.refresh_interval": "1s"
  }
}

For bulk loading, temporarily relaxing refresh can reduce segment churn:

curl -X PUT 'http://localhost:9200/logs-bulk/_settings'   -H 'content-type: application/json' -d '{"index.refresh_interval":"30s"}'

Do not leave production indexes with casually long refresh intervals unless the business accepts delayed visibility. A dashboard that looks five minutes stale is often 'working as configured.'

Flush and translog are durability machinery

The translog exists so acknowledged writes can survive a crash before a Lucene commit. Flush is not merely 'write data to disk' in the simplistic sense; it coordinates Lucene commit behavior and translog cleanup. Excessively small translogs or aggressive flush behavior can increase overhead. The operational lesson is not to tune these first. Tune bulk shape, shard count, mappings, and refresh first.

Bulk indexing is the write path that matters

Single-document indexing is for convenience, not throughput. Bulk APIs amortize network, coordination, and indexing work:

{"index":{"_index":"logs-2026.11.30","_id":"abc123"}}
{"@timestamp":"2026-11-30T13:04:11Z","service":"api","message":"timeout"}
{"index":{"_index":"logs-2026.11.30","_id":"abc124"}}
{"@timestamp":"2026-11-30T13:04:12Z","service":"api","message":"retry"}

There is no universal correct bulk size. Start around 5-15 MB or a few thousand documents, then measure. Watch bulk rejection counts, indexing latency, CPU, disk IO, and refresh impact. Larger is not better once memory pressure and queueing dominate.

Segment count and merge behavior affect everything

Frequent refreshes create many small segments. Searches fan out across those segments, and merges consume IO and CPU. Force merge can help read-only cold indexes:

curl -X POST 'http://localhost:9200/logs-2026.10.01/_forcemerge?max_num_segments=1'

Never force-merge a hot write index as a routine habit; you are burning IO while new writes continue to create segments. Use lifecycle transitions so optimization happens after writes stop.

Backpressure is a feature

429 or rejected execution exceptions during bulk indexing are not invitations to retry blindly forever. They mean the cluster is protecting queues and memory. Implement bounded retries with jitter, reduce concurrency, and inspect whether the bottleneck is indexing, disk, shard relocation, or an undersized coordinating path.

Field notes

  • Use deterministic document IDs for idempotent reindexing when possible; otherwise retries create duplicates.
  • Index sorting can help some read-heavy workloads but adds indexing cost and constrains the data model.
  • Watch indices.memory.indexing_pressure in modern distributions before assuming the disk is the only bottleneck.
  • Measure end-to-end visibility delay: application write time, refresh interval, replica behavior, and client caching all contribute.

Was this lesson helpful?

Sign in to rate