每秒150万条消息在3台机器上:对企业级Apache Pulsar的基准测试和延迟优化
1.5 Million Messages Per Second on 3 Machines: Benchmarking and Latency Optimization of Apache Pulsar at Enterprise Scale
AI总结:
本文通过企业级Apache Pulsar的基准测试和延迟优化,验证了在3台机器上每秒149.9947万条消息的性能,并通过硬件优化实现了每秒1500万条消息的吞吐量,同时解决了GC延迟和日志同步延迟问题。
摘要:
本文为Apache Pulsar从业者提出了两个独立贡献。首先,我们验证了在仅3台裸金属Kubernetes节点上运行Pulsar 4.0.8(Java 21和ZGC代垃圾回收)时,每秒可发布1,499,947条消息,中位数发布延迟为3.88 ms,并预测通过使用五个独立集群和基于键的分区路由,可在15台机器上实现每秒1500万条消息的吞吐量。硬件选择——特别是专用NVMe日志实现0.02 ms fdatasync和25 Gbps网络接口——是吞吐量上限的主要决定因素,而不是计算或软件调优。其次,我们追踪了从生产环境中213 ms的GC峰值和13-18 ms中位数发布延迟到3.88 ms的完整延迟优化旅程。三个独立的根本原因被识别并解决:通过切换到ZGC代消除了G1GC暂停;通过专用NVMe日志将日志fdatasync延迟从5.1 ms降至0.02 ms;以及在BookKeeper的ForceWriteThread中发现的之前未记录的Linux内核页面缓存写回交互,即使在物理上分离的NVMe驱动器共享内核块层时,也会将fdatasync从低于1 ms降级到15-22 ms。这一发现未在官方Apache Pulsar和BookKeeper文档中记录,并对所有经历未解释的P99.9延迟峰值的Pulsar操作员具有相关性。综合优化实现了在50倍更高吞吐量下的4.7倍延迟改进。
英文摘要:
This paper presents two independent contributions for Apache Pulsar practitioners. First, we validate 1,499,947 msg/s at 3.88 ms median publish latency on just three bare-metal Kubernetes nodes running Pulsar 4.0.8 with Java 21 and ZGC Generational garbage collection, and project a hardware-driven path to 15 million msg/s on 15 machines using five independent clusters with key-based partition routing. Hardware selection -- specifically dedicated NVMe journals achieving 0.02 ms fdatasync and 25 Gbps network interfaces -- is the primary determinant of throughput ceiling, not compute or software tuning. Second, we trace the complete latency optimization journey from 213 ms GC spikes and 13-18 ms median publish latency in production to 3.88 ms through Java Flight Recorder guided root cause analysis. Three independent root causes are identified and resolved: G1GC pauses eliminated by switching to ZGC Generational; journal fdatasync latency reduced from 5.1 ms to 0.02 ms through NVMe journal dedication; and a previously undocumented Linux kernel page cache writeback interaction inside BookKeeper's ForceWriteThread that degrades fdatasync from under 1 ms to 15-22 ms even across physically separate NVMe drives sharing the kernel block layer. This finding is undocumented in official Apache Pulsar and BookKeeper documentation and is relevant to all Pulsar operators experiencing unexplained P99.9 latency spikes. The combined optimizations achieve a 4.7x latency improvement at 50x higher throughput.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。