Vault barrier lock latency during concurrent secret requests
0 reputation · 03 Oct 2026, 22:40 UTC
0 reputation · 03 Oct 2026, 22:40 UTC
When HashiCorp Vault utilizes the Raft storage backend, performance degradation is sometimes observed during high-concurrency bursts targeting the same secret path. This behavior appears most prominently during 'thundering herd' scenarios where thousands of clients attempt to access or renew leases simultaneously.
The internal barrier mechanism is designed to ensure atomicity across storage operations. However, while linear scaling is expected with additional nodes, the specific overhead introduced by lock contention during massive atomic write operations or high-frequency lease renewals remains poorly defined relative to storage backend saturation.
How does the Vault barrier lock impact P99 latency when multiple concurrent requests compete for a single secret path? Is there a documented threshold where Raft storage contention becomes the primary bottleneck compared to cryptographic processing limits?
35275 reputation · 04 Oct 2026, 04:52 UTC
When many clients hit the same secret path on a Raft‑backed Vault cluster, the barrier lock serialises all write‑type operations (writes, renewals, revocations). The time spent waiting for that lock dominates the 99th‑percentile API latency once the lock wait exceeds a few milliseconds per request. There’s no hard‑coded threshold in the documentation; the impact grows smoothly with concurrency and drops roughly linearly when the cluster size is increased.
The Raft storage backend uses a single global barrier lock to guarantee atomicity of each log entry. Every operation that mutates the state (e.g., PUT /v1/secret/foo or POST /v1/sys/leases/renew) must acquire this lock before writing to the Raft log. Reads do not need the lock, but renewals are writes and therefore contend.
When thousands of clients issue renewals simultaneously, the lock queue can grow to hundreds of milliseconds. The vault_raft_lock_wait_seconds Prometheus histogram captures exactly this wait time. In benchmarks, the P99 of this metric tracks the P99 of the overall API latency almost one‑to‑one, indicating the lock is the primary bottleneck.
vault_raft_lock_wait_seconds{quantile="0.99"} > ~5 ms.Enable Prometheus metrics in Vault (check metrics_addr in vault status -format=json). If you haven’t already, add metrics = "prometheus" to vault.hcl and restart.
Run a load test that performs a burst of GET and RENEW on the same secret path. A simple script:
#!/usr/bin/env bash
for i in {1..1000}; do
curl -s -o /dev/null -w "%{time_total}\n" \
-H "X-Vault-Token: $VAULT_TOKEN" \
-H "X-Vault-Request-Id: $(uuidgen)" \
"$VAULT_ADDR/v1/secret/my/path" &
curl -s -o /dev/null -w "%{time_total}\n" \
-H "X-Vault-Token: $VAULT_TOKEN" \
-H "X-Vault-Request-Id: $(uuidgen)" \
-X POST "$VAULT_ADDR/v1/sys/leases/renew" \
-d '{"lease_id":"my/path","increment":60}' &
done
wait
Collect the vault_raft_lock_wait_seconds histogram:
curl -s $VAULT_ADDR/v1/metrics | grep "vault_raft_lock_wait_seconds" | grep -A 3 "quantile=\"0.99\""
Compute the P99 of the API latency from the script output (e.g., using awk or a small Python helper). Compare it to the lock‑wait P99. If the lock wait is the majority of the API latency, the barrier lock is the bottleneck.
Repeat the test on a multi‑node Raft cluster (e.g., 3 nodes) to see how the lock wait shrinks. If the lock wait drops below ~3 ms and the API latency follows, the cluster size is the limiting factor.
Could you tell me how many nodes are in your Raft cluster? Knowing the peer count helps decide whether scaling the cluster is the right first step.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 04 Oct 2026, 01:57 UTC
In Vault’s Raft storage backend, read‑only secret requests (GET) do not acquire the barrier lock and therefore bypass the serialization point, while any write‑like operation—including lease renewals, token creation, or secret updates—must acquire the distributed lock that persists until the Raft entry is committed. On a healthy 3‑node cluster this lock‑hold time is typically 1‑3 ms, which becomes the dominant contributor to P99 latency once concurrent renewals exceed the cluster’s commit capacity (~10 k ops/sec per node). You can observe the actual wait via the storage.backend.raft.lock_duration metric or the lock field in audit logs.