Search code examples
javamysqlspring-boothikaricpquartz

Is Springboot and Quartz Scheduler using same HikariCP?


I have a question about springboot, quartz scheduler and HikariCP. I am relatively new to this domain and trying to understand the relations and working. I have gone through many questions that are either related to Springboot HikariCP or Quartz scheduler using HikariCP but none of them is able to answer my questions.

I have an application with below configurations

#Database properties

spring.datasource.url = jdbc:mysql://localhost:3306/demo?user=root&password=root&useSSL=false&serverTimezone=UTC
spring.datasource.username = root
spring.datasource.password = root
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect

#Hikari

spring.datasource.hikari.minimumIdle=5
spring.datasource.hikari.maximumPoolSize=20

#quartz settings

spring.quartz.properties.org.quartz.jobStore.dataSource = quartzDataSource
spring.quartz.properties.org.quartz.dataSource.quartzDataSource.driver = com.mysql.cj.jdbc.Driver
spring.quartz.properties.org.quartz.dataSource.quartzDataSource.provider=hikaricp
spring.quartz.properties.org.quartz.dataSource.quartzDataSource.URL = jdbc:mysql://localhost:3306/demo?user=root&password=root&useSSL=false&serverTimezone=UTC
spring.quartz.properties.org.quartz.dataSource.quartzDataSource.user = root
spring.quartz.properties.org.quartz.dataSource.quartzDataSource.password = root
spring.quartz.job-store-type = jdbc
spring.quartz.properties.org.quartz.threadPool.threadCount=20

By default, springboot2 uses HikariCP. I have set the pool size to 20. In quartz scheduler too, I have set it to use HikariCP. Now my questions are

  1. Whether springboot and quartz using the same connection pool or quartz is creating a new pool?
  2. If quartz is creating a new pool, Is there any way to configure both such that both uses same connection pool created by springboot.
  3. What should be the optimal connection pool for 1k,10k,50k users?

Thanks in advance.


Solution

  • Sorry, don't have enough time to come back with a complete answer, but maybe this will help:

    1. you're giving the connection details in 2 different places, it's safe to assume you're creating 2 datasources with different pools.
    2. Found this: https://www.candidjava.com/tutorial/quartz-reuse-existing-data-source-connection-pool/
    3. The number of users can't be directly correlated to connection pool size. You should look at the number of concurrent requests you want to support: for 100 req/sec, each req taking 100 ms -> you need 10 connections. This is a very simplified way of calculating but it's a starting point, after that: monitoring and adjusting should help you.