Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Heuristic:Apache Dolphinscheduler HikariCP Pool Tuning

From Leeroopedia




Knowledge Sources
Domains Optimization, Data_Integration
Last Updated 2026-02-10 10:00 GMT

Overview

Connection pool tuning defaults for HikariCP in datasource plugins: minimum idle = 5, maximum pool size = 50, with ConnectionTestQuery-based validation.

Description

DolphinScheduler datasource plugins use HikariCP for connection pooling. The `BasePooledDataSourceClient` configures each pool with a default minimum idle of 5 connections and maximum pool size of 50. Connection health is validated using the database-specific `validationQuery` (e.g., `select 1`) via HikariCP's `ConnectionTestQuery` property. These defaults are externalized via property keys (`spring.datasource.min-idle` and `spring.datasource.max-active`) and can be overridden per deployment.

Usage

Apply this heuristic when deploying DolphinScheduler or tuning datasource plugin performance. The default pool size of 50 is appropriate for most deployments. Reduce the minimum idle (from 5) in resource-constrained environments or increase the maximum pool size when many concurrent task instances query the same datasource.

The Insight (Rule of Thumb)

  • Action: Configure HikariCP pool via property overrides for `spring.datasource.min-idle` and `spring.datasource.max-active`.
  • Value: Default minimum idle = 5, maximum pool size = 50.
  • Trade-off: Higher pool sizes consume more database connections (may hit DB `max_connections` limit). Lower minimum idle reduces idle resource usage but increases connection acquisition latency.
  • Validation: Each pool uses `ConnectionTestQuery` (not `testOnBorrow`) for health checks, which is HikariCP's preferred validation method.

Reasoning

HikariCP is the fastest Java connection pool. The default of 50 maximum connections accommodates DolphinScheduler's typical load pattern where multiple tasks may query the same datasource concurrently. The minimum idle of 5 ensures a warm pool without wasting connections. Using `ConnectionTestQuery` instead of `testOnBorrow` aligns with HikariCP's design philosophy of connection validation before each use.

Code evidence from `BasePooledDataSourceClient.java:62-64`:

dataSource.setMinimumIdle(PropertyUtils.getInt(DataSourceConstants.SPRING_DATASOURCE_MIN_IDLE, 5));
dataSource.setMaximumPoolSize(PropertyUtils.getInt(DataSourceConstants.SPRING_DATASOURCE_MAX_ACTIVE, 50));
dataSource.setConnectionTestQuery(baseConnectionParam.getValidationQuery());

The `close()` method at `BasePooledDataSourceClient.java:80-85` uses try-with-resources to ensure proper pool shutdown:

public void close() {
    log.info("do close dataSource {}.", baseConnectionParam.getDatabase());
    try (HikariDataSource closedDatasource = dataSource) {
        // only close the resource
    }
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment