Search latency appears only under concurrent request load
0 reputation · 29 Sept 2023, 22:12 UTC
0 reputation · 29 Sept 2023, 22:12 UTC
The goal is to determine whether the latency observed only when many search requests run concurrently is caused by search thread‑pool queuing or by other background activities such as translog flushes or refresh operations.
To isolate the effect, index‑level settings that influence refresh and translog behavior (e.g., refresh_interval, translog.flush_threshold_size) must remain unchanged while the concurrent request load is varied. Thread‑pool statistics (queue size and rejected count) should be collected alongside client‑side latency measurements to see if latency correlates with queue growth.
Does the search thread‑pool queue size increase proportionally with observed latency when the number of concurrent requests exceeds the configured thread‑pool size?
Is latency still present when the thread‑pool queue size remains zero despite high concurrent request volume?
31775 reputation · 30 Sept 2023, 09:25 UTC
Question 1: Yes — when concurrent search requests exceed the configured thread-pool size (default: number of available processors), the search thread-pool queue size grows proportionally with observed latency. Each queued request waits approximately (queue_position / throughput) before a thread becomes available.
Question 2: Yes — latency can persist even when the thread-pool queue size remains at zero. This indicates the bottleneck is not queuing but increased request processing time caused by CPU contention, GC pauses, I/O saturation, or background operations (refresh, translog flush, segment merges) competing for the same resources.
active == threads and new requests arrive.flush_threshold_size: 512mb) and rarely block search unless durability settings force synchronous flushes.merge thread pool; they compete for I/O and CPU but do not directly queue search requests.queue_size > 0 correlates with p99 latency spikes → queuing is the primary contributor.queue_size == 0 while p99 spikes → search threads are spending more time in CPU, GC, I/O wait, or lock contention (e.g., global refresh lock).GET _nodes/stats/thread_pool?level=nodePlot thread_pool.search.queue_size and thread_pool.search.rejected against client-side p50/p99 latency.GET _nodes/hot_threads?interval=500ms&type=cpu,wait,blockLook for search threads in WAIT (I/O, lock) or BLOCKED (synchronization) states.GET _stats/refresh,flush,mergeCorrelate deltas in refresh_total_time_in_millis, flush_total_time_in_millis, and merge_total_time_in_millis with latency spikes.PUT _settings
{
"index.search.slowlog.threshold.fetch.warn": "100ms",
"index.search.slowlog.threshold.query.warn": "100ms"
}Determine whether individual queries slow down or queue wait dominates.What is the sampling interval of your current thread-pool metrics collection? If it is longer than 2 seconds, transient queue spikes may be missed, leading to a false "zero queue" observation. Sub-second sampling (1–2s) is required to confidently rule out queuing.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.