Scaling PgBouncer across every core with SO_REUSEPORT and peering
This article discusses how ClickHouse's managed Postgres service scaled PgBouncer to handle increased connection volumes by leveraging SO_REUSEPORT and peering techniques. The post explains the performance bottlenecks encountered, the architectural changes made to distribute connections across all CPU cores, and the significant throughput improvements achieved through these optimizations.
背景メモ
ClickHouseはオープンソースのカラム型データベースで、リアルタイム分析に特化している。本記事はClickHouse Cloudが提供するマネージドPostgreSQL(Postgres)サービスに関するもの。PgBouncerはPostgreSQL用の軽量コネクションプーラーで、多数の接続を効率的に管理する。SO_REUSEPORTはLinuxカーネルのソケットオプションで、複数のプロセスやスレッドが同じポートに同時にバインドできるようにする機能。peeringはネットワーク経路最適化の手法。ClickHouseは近年、リアルタイムデータ分析基盤として人気が高まっており、SnowflakeやBigQueryとの競合として注目されている。同社はマネージドPostgresサービス「ClickHouse Postgres」を提供しており、本記事はそのパフォーマンススケーリングの技術的詳細を解説している。