Forum OpenACS Q&A: Re: decreasing the number of -sched:idleX- threads
The scheduled procedures are either executed in the main "-sched-" thread, or - when "ad_schedule_proc -thread t" is used - in a separate worker thread for scheduled procs. These worker threads can be reused by several scheduled procs.
The logic for starting the worker threads for scheduled procs is as follows: when a scheduled proc (with the thread flag) is to be started at a certain time, and there is no idle worker thread for scheduled procs available at this time, an additional worker thread is started. The worker threads are named either -sched:idleNN- (when they are idle) or -sched:NNN- when they are active (the threads are renamed depending on their state).
So, one can reduce the number of the worker threads for scheduled procs by either starting no scheduled procs with the thread flag (there can be at most one job active at one time) or by setting the (repeating) times for the scheduled procs more cleverly. Per default, many repeated threads start e.g. all 30/60 seconds, leading to "collisions" at starting time and multiple worker threads. Scheduling at different times (e.g. don't use multiples of some intervals for repeating threads) reduces the number of collisions.
NaviServer has additionally a config parameter "schedsperthread" that defines a maximum number of scheduled procs per worker thread, leading to a cleanup by terminating threads regularly. On our production site, we have 59 scheduled procs defined, 43 have the thread flag, and we have just 2 idle worker threads for scheduled procs.
Hope this helps!
thanks, Gustaw and Ryan