The performance optimization and tone of the XXL job core framework
The performance optimization and tone of the XXL job core framework
Introduction:
XXL job is an open source framework focusing on solving distributed timing task scheduling problems.In order to meet the needs of large -scale distributed task scheduling, the XXL Job Core framework provides flexibility and scalability.However, in practical applications, how to improve the performance of the XXL job core framework has become an important issue.This article will introduce some techniques of performance optimization and tuning to help you give full play to the potential of the XXL job core framework.
1. Increase the thread pool size of the task actuator
The XXL job core framework uses ThreadPoolexecutor as a thread pool of the task actuator.By increasing the size of the thread pool, the ability to execute the mission concurrent can be improved, thereby improving the overall performance of the framework.The following is an example of a Java code, showing how to set a larger thread pool size:
@Bean
public Executor xxlJobExecutor() {
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
100, 100, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(10000),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.AbortPolicy()
);
return new XxlJobSpringExecutor(threadPoolExecutor);
}
2. Adjust the parallelism of the task scheduling center
The task dispatch center of the XXL job core framework is responsible for dispatching all task actuators.By adjusting the parallelity of the task scheduling center, the efficiency of task scheduling can be improved.The settings of parallelism can be achieved by modifying `xxl.job.admin.thread.size` in the` application.properties` file of `xxl-job-admin`.
Third, reasonable configuration of the parameters of Jobexecutor
In Jobexecutor of the XXL Job Core framework, there are some configurable parameters that can affect the performance of the task scheduling.According to actual needs, the following parameters can be configured reasonably:
1. Executorparam -admin, you can set the appropriate name to facilitate identification and management in the task scheduling center.
2. ExecutorParam -Port, you can avoid conflicting port resource conflicts between multiple actuators by setting out uncontested port numbers.
3. LogretentionDays, you can control the retention time of the log by setting a smaller value to save storage space.
4. Use sharding tasks to reduce the execution time of a single task
For long -term execution tasks, you can consider dividing it to increase the concurrency of the task, thereby reducing the execution time of a single task.By using the `@xxljob (value =" jobhandler ", distributedtask = true, ShardParams =" 0 = 1,1 = 2,2 = 3 "), you can schedule the sliced scheduling of tasks in the task scheduling center.
5. Reasonable configuration of the parameters of the task scheduling trigger
In the XXL Job Core framework, the task scheduling trigger is responsible for triggering the execution of the task according to the setting of the settings.The parameters of the trigger can be scheduled by a reasonable configuration task can be improved to improve the efficiency of task scheduling.For example, setting a small task timeout time, reasonable number of tasks failed, and the number of retries.
6. Avoid conflicting concurrency during the execution of the task
When multiple task actuators perform the task concurrently, there may be problems with concurrency, such as multiple actuators writing operations on the same database at the same time.In order to avoid complications, a distributed lock mechanism can be used, such as using a distributed lock of Redis to ensure the concurrent security of the task execution.
Summarize:
Through the above performance optimization and tuning skills, the potential of the XXL job core framework can be fully used to improve the efficiency and performance of task scheduling.According to actual needs and scenes, reasonably configure task actuators, task scheduling centers, and use the sliced task, reasonably configure the parameters of the trigger of the trigger, and avoid the complicated conflict during task execution.And stability.