I'm building a IFTTT like platform here.
In short, rufus scheduler is great. and I know it uses thread pool(28 threads by default? => 3.x.x)
My platform is expected to handle more than 1000 schedules maybe more than that.
on Jruby, as Singleton. Is there a performance problem with this expectation? should I increase max thread pool size? then how many threads should I increase? Is there a guide for this issue?
I completed benchmark, code is as below.. My system has a job queue in it, so rufus-scheduler's handler is going to do very short and light tasks only. For example queueing jobs. In code, Just logging interval between job.last_time and time. I assumed the bigger the interval, the lower performance. like "delayed"
require 'rufus-scheduler'
require 'awesome_print'
require 'logger'
SCHEDULE_COUNT = 1000
MAX_THREAD = 224
schedule_samples = { type: "cron", schedule: "* * * * *"}
$logger = Logger.new("benchmark.log")
scheduler = Rufus::Scheduler.singleton(:max_work_threads => MAX_THREAD)
class Handler
def self.call(job, time)
$logger.info job.last_time - time
end
end
SCHEDULE_COUNT.times do
scheduler.send( schedule_samples[:type].to_sym, schedule_samples[:schedule], Handler)
end
sleep 600
The result is a little bit disappointed.. the more threads, the better. But I got the approximate delay for my future system, and it's reasonably acceptable.
I ran this code at my laptop, 1 core 1GB RHEL 64bit Vmware and 4 core 4GB RHEL 64bit Vmware.
Jruby version
These are not exactly same, but it should be okay..? The link chart is average of all intervals. Benchmark Result
I can keep increase max threads to find out the performance peak. But I decide won't do it. I gonna use better machine for production environment. 1000 ~ 2000ms delay shouldn't be a problem. (in benchmark largest delay was 700ms at 1 Core)