Confluent

Apache Kafka, Purgatory, and Hierarchical Timing Wheels | Confluent

Oct 28, 2015Yasuhiro Matsuda
Apache Kafka, Purgatory, and Hierarchical Timing Wheels | Confluent
SummaryAI, from the source post

This post details the redesign of Kafka's request purgatory to address performance and memory issues. It explains the deficiencies of the old design, which used Java's DelayQueue and suffered from inefficient purging, leading to potential OutOfMemoryErrors and performance bottlenecks. The new design introduces Hierarchical Timing Wheels and doubly linked lists to achieve O(1) insert/delete for completed requests and a more efficient purging strategy. It also optimizes the driving clock by enqueuing task buckets instead of individual tasks into DelayQueue. Benchmark results show a dramatic improvement in enqueue performance, with the new implementation handling significantly higher RPS and exhibiting better CPU usage compared to the old design, especially under high load and memory-constrained conditions.