Quartz clustering load balancing algorithm internal implementation in Jdbcjobstore

雨燕双飞 提交于 2019-12-01 13:23:04

Quartz uses no explicit load-balancing. What happens is that individual clustered Quartz scheduler instances compete to execute jobs. When the time comes and a job should be executed, individual scheduler instances attempt to create a DB row lock in the QRTZ_LOCKS table in the configured job store database. The instance that manages to create the DB row lock wins and executes the job. The other scheduler gets an SQL exception and gives up.

As you can deduce, load-balancing in Quartz is very simple as nodes with higher load are "somewhat less likely" to be the first ones to successfully create the DB lock. This obviously assumes the time is properly synchronized on all clustered Quartz instances.

If you are interested in how the DB row locking works in Quartz, you can check the DBSemaphore API.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!