Web / Apache Solr Interview questions
How do you optimize Solr for high-throughput near real-time indexing?
High-throughput NRT indexing means tuning the tension between "documents should appear searchable quickly" and "commits and merges are expensive," rather than chasing either extreme.
- Tune commit intervals separately. Set a short
autoSoftCommit(e.g. 1-3 seconds) for visibility, and a longerautoCommitwithopenSearcher=false(e.g. 60 seconds) purely for tlog durability - conflating the two forces unnecessary full searcher reopens. - Batch writes and use concurrent clients. Many small single-document requests waste time on HTTP/JSON overhead; batching into a few hundred documents per request, sent from multiple threads, uses available CPU cores far better.
- Increase ramBufferSizeMB so more data accumulates in memory before a segment flush, reducing small-segment churn that background merges then have to clean up.
- Separate indexing and query load using replica types - route heavy indexing to NRT/TLOG leaders while PULL replicas absorb read traffic, so query latency doesn't spike every time a large batch lands.
- Watch merge behavior under load - if merges can't keep up with incoming segments, query latency degrades; increasing merge threads or adjusting the tiered merge policy's segments-per-tier can relieve this.
The right balance is workload-specific: a system ingesting logs at extremely high volume might accept a slightly longer soft-commit interval to protect query latency, while a live inventory system might need sub-second visibility and tolerate more merge overhead in exchange.
More Related questions...