Limit of scheduleAtFixedRate

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
Posts: 12
Joined: 06 Jan 2018, 10:11

Limit of scheduleAtFixedRate

Postby Pirisok » 16 Sep 2019, 11:32

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?
User avatar
Site Admin
Posts: 21647
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Limit of scheduleAtFixedRate

Postby Lapo » 16 Sep 2019, 15:19

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
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 17 guests