11 min read

πŸ”₯ Taming the Tail: How Probabilistic Quorum Adjustments + RDMA Slashed Our P99 Latency from 800ms to 12ms

Slashing P99 Latency to 12ms via Probabilistic Quorums and RDMA

πŸ”₯ Taming the Tail: How Probabilistic Quorum Adjustments + RDMA Slashed Our P99 Latency from 800ms to 12ms

Spoiler: We turned a globally distributed database into a quantum-level fast consensus machine. Here’s how.

The Hook: When 400ms Feels Like a Century

Picture this: You’re watching a live sports stream. A goal is scored. Your friends in Tokyo see it 200ms before you in New York. Annoying, but tolerable. Now imagine that delay is your database commit time for a critical financial trade. 200ms isn’t just annoyingβ€”it’s millions of dollars in arbitrage losses.

For years, the holy grail of distributed databases has been strong consistency with single-digit millisecond tail latency, even when replicas sit in SΓ£o Paulo, Sydney, and Stockholm. We’ve all been told it’s impossible: the CAP theorem says you have to choose. The network says latency = distance / (2/3 speed of light). Physics says tough luck.

We decided to rewrite the physics textbook.

After 18 months of blood, sweat, and iterative kernel patches, we built a system that consistently delivers P99 tail latency under 15ms for committed writes across 3 continents. The secret sauce? A marriage of Probabilistic Quorum Adjustments (PQA) and RDMA-enabled Paxos consensus that adapts the quorum size in real-time based on network entropy, without sacrificing linearizability.

Let’s rip the hood off this beast.


The Problem: The Tail Isn’t Just Heavyβ€”It’s Asymmetric

In any globally distributed database, latency isn’t a single number. It’s a distribution. And the P99.9 tail is where distributed systems go to die.

Take a standard Multi-Paxos or Raft setup with 5 replicas (across US-East, US-West, EU-West, EU-Central, AP-Southeast). A leader in US-East proposes a value. It must wait for an acknowledgment from a majority (3 out of 5). In theory, the lucky 3rd ack might come from US-West (30ms RTT). In practice? The 3rd ack might come from AP-Southeast (200ms RTT).

Result: Your average latency might be 80ms, but your P99 explodes to 400-800ms due to:

  • Cross-continental packet loss causing retransmits on TCP.
  • GC pauses on the replica handling the 5th ack.
  • Network queueing at congested peering points.
  • The β€œstraggler problem”—one slow node forces the entire quorum to wait.

We needed a system that could dynamically shrink or grow the quorum based on current network conditions, without breaking consistency. Enter Probabilistic Quorum Adjustments.


The Core Insight: Quorums Aren’t Sacredβ€”Probability Is

Traditional quorums are binary: you have a majority, or you don’t. We rejected this rigid view. Our system treats consensus as a probabilistic process guided by stochastic dominance.

Here’s the key idea:

Why wait for the 3rd slowest node when you can mathematically prove that 2 fast nodes are β€œas good as” 3 slow ones?

The Math (Don’t Panic)

Let’s define a quorum quality function Q(S) for a set of replicas S:

Q(S) = Σ_{i ∈ S} w_i · P(availability_i) · RTT_i^{-1}

Where:

  • w_i = weight of replica (hardware capability, e.g., NVMe vs SATA).
  • P(availability_i) = probability node i will respond within a deadline.
  • RTT_i = current smoothed round-trip time.

Standard quorum: Accept if |S| β‰₯ majority (e.g., 3 of 5). Our quorum: Accept if Q(S) β‰₯ Q_threshold, where Q_threshold is dynamically tuned.

This means: if two nodes in New York and London have extremely high availability and sub-1ms RTT between them due to RDMA over dedicated fiber, their combined Q(S) might equal a 3-node quorum that includes a slow Sydney node. We can safely commit with 2 nodes while bypassing 1.

But waitβ€”isn’t this dangerous? Yes, unless you can guarantee safety. That’s where RDMA and probabilistic reasoning intersect.


RDMA: The Secret Weapon That Makes This Safe

Remote Direct Memory Access (RDMA) isn’t just about speedβ€”it’s about determinism. When we use InfiniBand or RoCE v2 with Mellanox ConnectX-6 cards, we bypass the kernel network stack entirely.

What RDMA Gives Us:

  1. Zero-Copy Operations: Data goes directly from application buffer to remote memory.
  2. Sub-1Β΅s Latency: No context switches, no interrupts.
  3. Bounded Tail: RDMA’s tail latency is typically < 3x mean, vs TCP’s 100x.

But the killer feature for our probabilistic quorum? RDMA atomics (specifically, fetch-and-add and compare-and-swap).

How We Use RDMA Atomics

In standard Paxos, each acceptor writes its β€œpromised” or β€œaccepted” value to disk (or a replicated log). This is slow. Instead, we encode proposal numbers and accepted values directly into RDMA-accessible memory regions on the remote nodes.

// Pseudocode for our RDMA-backed Paxos accept phase
uint64_t current_proposal = rdma_atomic_fetch_add(proposal_counter, 1);
struct paxos_value value = build_value(current_proposal, data);

// Write value to all remote replica memory regions simultaneously
for (replica : candidates) {
    rdma_write(replica->memory_region, &value, sizeof(value));
}

// Spin-wait for acks using RDMA read-policing (no interrupts!)
while (num_acks < required_quorum_w) {
    // Read remote "ack_flag" via RDMA
    if (rdma_read(replica->ack_flag) == COMPLETE) {
        num_acks++;
    }
    // If some nodes haven't responded, check others
}

Because RDMA reads are non-blocking and deterministic, we can predicate our quorum decision on observed latencies in real-time. If a node hasn’t responded within 500Β΅s, we simply exclude it from the quorum and use the next fastest node.

But what if two different leaders propose conflicting values? This is where the probabilistic adjustment meets safety.


Probabilistic Quorum Adjustment (PQA): The Algorithm

Our algorithm runs in a control loop on every node, constantly updating a latency histogram and availability score for every other replica.

Step 1: The Entropy Detector

Each node maintains a Sliding Window Availability Matrix (SWAM) of last 1,000 RTTs per peer. We compute network entropy H:

H = - Ξ£ (f_i Β· logβ‚‚ f_i)

Where f_i is the frequency of RTTs in bucket i (0-5Β΅s, 5-20Β΅s, 20-100Β΅s, etc.). High entropy β†’ volatile network. Low entropy β†’ stable.

Step 2: Dynamic Quorum Threshold

In low-entropy regimes (stable network), we can safely reduce the required quorum quality Q_threshold by 20%. This allows us to commit with 2 fast nodes instead of 3.

In high-entropy regimes (jittery network), we increase Q_threshold to require 3 or even 4 nodes, because the probability of a false positive (thinking a node is fast when it’s actually about to die) increases.

Step 3: The β€œRisk Budget”

Every leader proposing a value must β€œspend” a risk budget equal to the probability that the chosen quorum overlaps with a conflicting quorum. This is calculated using hypergeometric distribution:

P_overlap = 1 - (C(N - Q, Q) / C(N, Q))

Where N is total replicas, Q is the probabilistic quorum size. If P_overlap > 10^-6 (our safety margin), the leader must add one more node to the quorum.

Real-world example: In a 5-node cluster:

  • Standard majority: 3 nodes β†’ `P_overlap = 1 - (C(2,3)/C(5,3)) = 1 - 0 = 0% overlap risk (safe).
  • Our 2-node fast quorum: `P_overlap = 1 - (C(3,2)/C(5,2)) = 1 - 0.3 = 70% overlap risk β†’ TOO HIGH.

But waitβ€”our quorum isn’t random 2 nodes. It’s the 2 fastest nodes. Their probability of being chosen by a concurrent leader is lower because the other leader also prefers fast nodes. This creates biased choice correlation that reduces overlap risk. We model this with copula theory and Dirichlet processes. (Yes, this is where the math gets spicy.)


Infrastructure: The Boring But Crucial Stuff

You can’t run this on AWS t3.micro instances. Here’s our exact stack:

Hardware

  • Nodes: 3x per region, each with AMD EPYC 7763 (64-core), 512GB DDR5, 10 NVMe drives in RAID 0 (for log writes).
  • Network: Dedicated Mellanox ConnectX-7 dual-port 200Gbps InfiniBand. Each fiber bundle is actively cooled using liquid dielectric.
  • Distance: US-East ↔ EU-West = 58ms physical round trip (plus fiber patch panel detours). We negotiated dark fiber directly from Equinix to reduce hops.

Software Stack

  • Kernel: Patched Linux 6.4 with custom RDMA scheduler that prioritizes consensus traffic over batch processing.
  • Consensus Library: Modified bRaft (a blazing fast Raft implementation) with Paxos-style multi-leader support. We swapped the default TCP heartbeats with RDMA spin-loops.
  • Failure Detection: SWIM-style gossip protocol, but accelerated via RDMA multicast writes to a shared memory region.

The Cooling Story (Engineering Curiosity)

Our InfiniBand transceivers push 15W per port. In a 12-node cluster with 6 links each, that’s ~1kW of heat just from optics. We custom-designed a per-port liquid cold plate using 3D-printed aluminum channels. The coolant is a dielectric Novec fluid that boils at 49Β°Cβ€”perfect for two-phase cooling. The vapor travels to a rooftop condenser. No fans in the room. The silence is eerie.


The Heavy Lifting: How We Beat the Tail

Let’s trace a realistic write operation from a mobile user in SΓ£o Paulo to our database cluster.

Setup: 5 replicas (SΓ£o Paulo, US-East, US-West, EU-West, Tokyo). Leader initially in US-East.

  1. User sends write request to SΓ£o Paulo proxy.
  2. Proxy routes to closest leader (US-East, 120ms away due to undersea cable path via Africa, not direct).
  3. Leader begins quorum selection:
    • RDMA reads SΓ£o Paulo’s SWAM. Entropy = 0.14 (very stable).
    • Reads US-West’s SWAM. Entropy = 0.89 (jittery because of AWS peering congestion).
    • Decision: Exclude US-West. Quorum = {US-East, EU-West, SΓ£o Paulo}.
  4. Leader sends proposal via RDMA:
    • To EU-West: 1.2ms (dedicated fiber).
    • To SΓ£o Paulo: 119ms (slow but unavoidable).
  5. RDMA write completes to EU-West in 1.2ms. EU-West’s ack_flag is set.
  6. Spin-wait for SΓ£o Paulo: After 119ms, ack received.
  7. But waitβ€”our PQA threshold was met after just 1.2ms? No! The algorithm required Q(S) β‰₯ 0.8 (normalized). US-East + EU-West gave Q = 0.95 due to their high RTT weights. We could have committed after 1.2ms!

The key optimization: If the first two RDMA-slow nodes (sub-2ms) meet the Q_threshold, we don’t send to the third node. The SΓ£o Paulo node never even receives the proposal. The write commits in 1.2ms instead of 120ms.

P99 tail before: 800ms (thanks to TCP retransmits on the SΓ£o Paulo leg). P99 tail after: 12ms. The rare 12ms cases occur when ALL fast nodes have momentarily high entropy, forcing us to include a slow node.


The Danger Zone: When It Almost Broke

On Black Friday 2023, a submarine cable cut between UK and US-East caused 40% packet loss on our primary fiber. Entropy in US-East shot to 1.7 (maximum). Our PQA algorithm immediately increased the Q_threshold and added all 5 nodes to the quorum.

But something worse happened: One of our RDMA adapters on the Tokyo node had a silent memory corruption due to a cosmic ray bit flip. The node’s memory region was showing ack_flag = TRUE even though it hadn’t actually received the value.

We caught it because our probabilistic model also tracks Bayesian confidence intervals on ack honesty. The probability that Tokyo’s ack was valid given its observed latency distribution was < 0.001. The leader rejected the ack and retried with a different node.

Lesson: Probabilistic quorums are only as safe as your honesty model. We now run mandatory cryptographic signatures on every RDMA write, verified via hardware TPMs before counting the ack.


The Results: Data That Speaks Loudly

We ran a 30-day benchmark with 5 replicas across the globe, using YCSB workloads with 1KB payloads. Each point below is over 1 billion operations.

MetricTraditional Multi-Paxos (TCP)Our RDMA + PQA SystemImprovement
Median latency95ms2.1ms45x
P99 latency820ms12ms68x
P99.9 latency2.3s47ms49x
Throughput120K ops/sec890K ops/sec7.4x
Quorum sizeFixed 3/52.3 average (range 2-4)-23% nodes per commit

The tail didn’t just shrinkβ€”it vanished. Our P99/P50 ratio is 5.7, compared to 8.6 for traditional systems. That’s the mark of a bounded tail system.


The Future: Where We Go From Here

We’re currently experimenting with:

  1. Predictive quorum formation: Using LSTM neural networks to forecast network entropy 5 seconds in advance, pre-emptively adjusting quorum sizes.
  2. Multi-DC quorums with quantum key distribution: If we can share entanglement-based encryption keys between data centers, we can reduce the overhead of crypto verification on each RDMA ack.
  3. Self-healing RDMA links: Using optical cross-connects to route around fiber cuts in under 100ms, triggered by our entropy spikes.

Final Thoughts: This Isn’t Magicβ€”It’s Math

Optimizing tail latency isn’t about buying faster hardware (though it helps). It’s about embracing the probabilistic nature of the network rather than fighting it. By treating quorum size as a continuous variable constrained by entropy and risk budgets, we turned a rigid protocol into an adaptive, living system.

The next time your database reports a P99 of 200ms, ask yourself: Is the problem the network, or the fact that you’re treating all nodes as equals when they clearly aren’t?

Our answer: Throw out dogma. Embrace probability. Add RDMA. Watch your tail disappear.


Want to dive into the code? Our RDMA-backed Paxos implementation is open-source at github.com/yourcompany/quorumator. Contributions welcomeβ€”especially from those who dream in probabilities.

About the author: I’m a staff engineer at Hyperscale DB, where I spend my days breaking the CAP theorem with brute force and elegant math. Previously at Google Spanner and Amazon DynamoDB. In my free time, I overclock InfiniBand adapters with liquid nitrogen. 🧊


More to explore

Keep diving in