Quartz Theory of Timed Task Java Writing Review (2)

3.4 How many tasks can   Quartz run?

See what environment it depends on.

First, the JobStore has a significant impact on performance . A RAM -based JobStore is much faster than a JDBC -based JobStore . The speed of a JDBC -based JobStore depends almost entirely on the speed of the connection to the database, as well as the data system used and the hardware the database is running on. The Quartz itself actually does very little processing, and almost all of its time is spent on the database. Of course, RAMJobStore has a limit on how many "tasks" or "triggers" can be stored, because the amount of memory is much smaller than the disk space of the database.

Therefore, the limiting factor in time for the number of triggers and tasks that Quartz can store and monitor is the amount of storage space available to the JobStore . (The amount of memory or the number of hard drives).

What can make Quartz itself run slower is the use of a large number of listeners ( TriggerListeners, JobListeners, and SchedulerListeners ), in addition to the actual running time of the task itself, the time spent on each listener is directly credited to the "processing" task. in execution time. This does not mean to be afraid of using listeners because of this, but to use them wisely. Don't create a lot of "global" listeners if you can use specific listeners, and don't use listeners for "time-consuming" work unless you have to.

How many tasks can run at the same time is limited by the size of the thread pool. If there are 5 threads in the pool , no more than 5 tasks can run concurrently . Be careful when using a large number of threads, because the JVM, operating system and CPU are time consuming to process large numbers of threads, and thread management can also cause performance degradation. In most cases, performance starts to degrade because up to hundreds of threads are used. If you run the program in an application server, be aware that the application server itself has created a lot of threads.

In addition to these factors, it is also related to the tasks to be performed, if tasks take a long time to complete their work, and/or their work is CPU-intensive, then obviously do not run multiple tasks at the same time, and do not Too many such tasks run in one time period.

 

3.5 Job Scheduling

The task is executed when the given trigger ( Trigger ) fires. Triggers can be created in almost any combination of the following:

At any time of day (can be accurate to the millisecond).

certain days of the week.

specific days of the month.

certain days of the year

Some days (such as holidays) that are not registered in the calendar list.

loop a specific number of times

Loop to a specific time.

Infinite loop

Loop at certain time intervals.

 

The task needs to be given a name and can be added to the task group with the given name. To simplify trigger management in schedules, Triggers can also be given names and groups. A task can only be added to a schedule once, but multiple triggers can be registered for it. In a J2EE environment, tasks can be executed as part of a distributed (XA) transaction.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326946159&siteId=291194637
Recommended