Cloudflare reduced double-spend check latency in their privacy proxy service from 40ms to under 1ms by fixing a TCP networking issue. The problem was caused by Nagle's algorithm and delayed ACKs interacting poorly when sending memcached commands in multiple small packets. The solution involved using BufWriter to buffer writes and send complete commands in single packets, eliminating the 40ms delay caused by TCP's delayed acknowledgment mechanism.

9m read timeFrom blog.cloudflare.com
Post cover image
Table of contents
How did we discover the issue?The expected latencyHow did we investigate the issue?Theory 1: health check takes longTheory 2: waiting to get a connectionTheory 3: delays in Nagle’s algorithm and delayed acksWhy 40 ms?The fixConclusion

Sort: