Page 1 of 1

Limit of scheduleAtFixedRate

Posted: 16 Sep 2019, 11:32
by Pirisok
I just wanna ask is there any limit of how much schedules we can run in our extension like this :

Code: Select all


I'm running about 5 of them, every is working but I want to know that is there any limit or should I reduce them?

Re: Limit of scheduleAtFixedRate

Posted: 16 Sep 2019, 15:19
by Lapo
there is no specific limit. Essentially it depends on these variables:

1) number of threads in the Scheduler
2) how frequent your tasks are
3) how long does it take for a task to complete
4) the number of tasks


1) Scheduler uses 1 thread
2) Tasks run every second
3) A task completes in 10ms
4) We run 20 tasks

We only run one thread so these tasks will execute in sequence. Because every task completes quickly (10ms) it will take 20x10ms = 200ms to complete them all which is good. All the tasks will complete before it's time to run again.

However if you imagine that the task now takes 100ms, we have a problem. The total execution time for all tasks exceeds their requested interval (once per second) so they will end up running late, not on schedule anymore.

To fix the problem you can add more threads, so that when one thread is busy the other can keep up with the work and avoid delays.

Hope it helps