ClickHouse's Dual-Window Auto-Scaling: Faster, Cheaper

Alps Wang

Alps Wang

Mar 27, 2026 · 1 views

The Art of Dynamic Resource Allocation

The core innovation of the two-window recommender is elegant and directly addresses a common pain point in auto-scaling systems: the trade-off between responsiveness and stability. By decoupling scale-up and scale-down logic using distinct lookback windows, ClickHouse has achieved a more nuanced and efficient resource management strategy. The 3-hour window for scale-down provides the necessary agility to react to traffic drops without causing oscillations, while the 30-hour window ensures robust scale-up capabilities, preventing the need for multiple gradual adjustments that can invalidate caches and disrupt performance. The introduction of the target-tracking CPU recommendation system is equally crucial, moving away from the problematic fixed-factor scaling that led to cascading over-provisioning and oscillations. This shift to a utilization-based approach, with mathematically sound reversible scaling guarantees via the geometric mean, represents a significant leap in algorithmic sophistication for database auto-scaling.

However, while the article highlights the benefits for variable workloads, a potential limitation could be the complexity introduced for users who prefer simpler configuration or a deeper understanding of the internal workings. Although the article mentions user-facing configuration is available in ClickHouse Cloud documentation, the underlying complexity of two windows and target-tracking might still pose a learning curve. Furthermore, while the 3-hour window was found to be optimal, the exact 'sweet spot' for such windows can be highly workload-dependent, and tuning might still be required for extreme or highly cyclical traffic patterns. The article also focuses on vertical scaling; the implications and integration of this approach with horizontal scaling strategies, while mentioned, could benefit from more detailed exploration of how they complement each other in a real-world, distributed environment.

Key Points

  • ClickHouse introduced a two-window auto-scaling recommender to balance fast scale-ups and faster scale-downs.
  • A 3-hour window handles recent usage for quick scale-downs, while a 30-hour window captures long-term peaks for stable, single-step scale-ups.
  • A new target-tracking CPU recommendation system replaced a problematic fixed-factor approach, calculating precise resource needs based on target utilization.
  • Target-tracking uses a threshold band and geometric mean for reversible scaling and avoids minor fluctuations.
  • Memory recommendations are also generated per window, with the system selecting the higher recommendation for CPU/memory scaling.
  • Automatic idling is a separate feature for periods of complete inactivity, suspending compute resources for cost savings.
  • The new system reduces scale-down latency from 30 hours to 3 hours, minimizes oscillations, and cuts infrastructure costs.

Article Image


📖 Source: Smarter Auto-Scaling for ClickHouse: The Two-Window Approach

Related Articles

Comments (0)

No comments yet. Be the first to comment!