How does the job cache and polling relate to each other? #361
-
Hey! We're currently reading through the documentation again, the code and also some closed issues to better understand how GoodJob works and what to expect. For us, the documentation doesn't make it perfectly clear how the job cache and polling work together. Thanks to the super interesting discussion and this comment here: #90 (comment) we think that the following happens:
Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Fantastic question! Let me try to explain this cohesively, and then please poke holes in it. Every The job cache lives at the thread pool executor level, which is a The job cache isn't really a cache of specific jobs, but is a pile of Polling does not fill the job cache. Polling just pokes the scheduler(s) with the same "there might exist a runnable job right now, you should check". The Poller does not have knowledge of the database, it simply pokes the Scheduler. Cron is isolated from Schedulers, and enqueues unscheduled jobs at regular intervals, which (as part of enqueue) pokes the Scheduler(s) with the same "there might exist a runnable job right now, you should check". Which I think leads to the important question: how to size the job cache and how frequently to poll?
Practically: I think the Production environment should always poll as a belt-and-suspenders at an interval that is the maximum scheduled latency you will accept. BTW, if you are using |
Beta Was this translation helpful? Give feedback.
Fantastic question! Let me try to explain this cohesively, and then please poke holes in it.
Every
perform_later
job gets written to the database, regardless of whether it's now orwait
/wait_until
. (fyi,perform_now
always sidesteps the Adapter and runs directly by ActiveJob, that's an ActiveJob thing and commonly trips people up). Only jobs that have await
/wait_until
will go into the job cache.The job cache lives at the thread pool executor level, which is a
GoodJob::Scheduler
. If you're using multiple pools with a semicolon (GOOD_JOB_QUEUES="mice:2;elephants:3"
), your process has multiple Schedulers, and thus multiple job caches.The job cache isn't really a cache of specific jobs, but…