toptal / active-job-style-guide

This Background Jobs style guide is a list of best practices working with Ruby background jobs.
471 stars 20 forks source link

Future enhancements to the guide #1

Open pirj opened 5 years ago

pirj commented 5 years ago

This is a bag of thoughts issue, I encourage everyone to file more specific detailed issues and send pull requests.

fwolfst commented 7 months ago

Misses mention of https://github.com/sidekiq/sidekiq/wiki/Advanced-Options#transactional-push (if you enqueue in transactions, you likely want to use this)

pirj commented 1 month ago

Add a guideline to not pass large arguments to jobs, as they consume storage memory. This is especially risky for Redis which may just stop accepting jobs, causing issues. This is partially solved by Sidekiq reliable push, but only while the process is alive: chances are a web server will be rebooted before it has a chance to submit those jobs temporarily stored in memory. With ephemeral file systems, and jobs scheduled outside of db transactions (rather after commit), this is a way to losing jobs. While other storages like pg don’t apply the same hard constraints on the jobs storage, and won’t cause a problem when a memory limit is hit, but they come with other unwanted side effects as postgres toast. Ask que/good_job/solidqueue guys what is they experience with storing many jobs. Off the top of my head, good_job had a note about processing millions of jobs, not more, which is not much compared to what I’ve seen with Sidekiq and Redis, thousands a second, over 50M daily, with each job having more than 1k of payload, and occasional jams of millions of jobs to process.