Quartz clustering load balancing algorithm internal implementation in Jdbcjobstore

℡╲_俬逩灬. 提交于 2019-12-19 10:46:13

问题


I have configured quartz in my application. It works on cluster and i can see cluster nodes are triggering jobs one at a time. However, i have a question about how load balancing algorithm works in quartz. I want to know at what point in jdbcJobstore code, a node get information that it can not acquire a lock.How a particular cluster node acquire a lock to trigger a job in code?


回答1:


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.



来源:https://stackoverflow.com/questions/30521134/quartz-clustering-load-balancing-algorithm-internal-implementation-in-jdbcjobsto

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