基于XXL-JOB的分布式定时任务研究和应用

2022-06-21 01:14:24郑祥,顾丹鹏,陈肖勇
计算机时代 2022年6期

郑祥,顾丹鹏,陈肖勇

摘  要: 随着微服务架构成为主流,单体定时任务由于单点故障等问题渐渐无法满足平时的业务需求。分布式定时任务通过集群的方式进行管理调度,大大降低了开发和维护成本。通过分布式部署,保证了系统的高可用,伸缩性,提高了容错率。XXL-JOB拥有优秀的可视化界面,使用方便灵活高效。对比市场上的主流定时任务框架,基于XXL-JOB给出了一种分布式定时任务的解决方案,并在石坞实验室项目进行了部署和使用。

关键词: 微服务; 分布式; 定时任务; XXL-JOB

中图分类号:TP399          文献标识码:A     文章编号:1006-8228(2022)06-80-03

Distributed timing task deployment based on XXL-JOB

Zheng Xiang1,2, Gu Danpeng1,2, Chen Xiaoyong1,2

(1. PowerchinaHuadong Engineering Corporation Limited, Hangzhou, Zhejiang 311122,China;

2. Zhejiang Huadong Engineering Digital Technology Co.Ltd)

Abstract: As the microservice architecture becoming the mainstream, the single timing task can not meet the usual business needs due to single point of failure and other problems. Distributed timing tasks are managed and scheduled by cluster, which greatly reduces the development and maintenance cost. Through distributed deployment, the high availability, scalability and fault tolerance of the system are ensured. XXL-JOB has an excellent visual interface, which can deploy and manage timing tasks through the console, and is convenient, flexible and efficient. Compared with the mainstream timing task framework in the market, a distributed timing task solution is given based on XXL-JOB, which is deployed and used in Shiwu laboratory project.

Key words: microservices; distributed; timing task; XXL-JOB

0 引言

隨着业务场景变得越来越复杂,定时任务在程序设计中存在广泛应用。刚开始企业发展规模较小,业务范围有限,所以定时任务的需求也很少,这时定时任务可以直接在单台服务器节点上进行部署,而且基本不需要对这些任务进行控制和管理,任务也能顺利执行[1]。当然,这种方式会导致单点故障的问题,所以企业一般就会采用多台服务器节点进行备份来保证任务的成功执行。而随着企业的发展规模越来越大,业务逻辑愈加复杂,导致定时任务的需求量也在不断攀升。此时单个服务器节点已经无法承载众多定时任务同时执行,需要部署多台服务器节点来执行这些定时任务。而定时任务的调度问题也随之而来,首先是定时任务的路由分配问题,即:应该由哪台服务器执行这个任务。其次是在分布式部署的情况下,定时任务的调度信息,执行状态的监控如何获取。……

登录APP查看全文