Performance: Scheduled jobs
MEDIUM IMPACT
Scheduled jobs affect background processing speed and server resource usage, indirectly impacting user experience by offloading work from request cycles.
class CleanupJob < ApplicationJob queue_as :default def perform(batch_size: 100) User.find_in_batches(batch_size: batch_size) do |users| users.each { |user| user.posts.destroy_all } end end end # Scheduled with cron and uses batch processing with Sidekiq concurrency
class CleanupJob < ApplicationJob queue_as :default def perform User.all.each do |user| user.posts.destroy_all end end end # Scheduled with cron to run every hour synchronously
| Pattern | Server Load | Blocking Time | Resource Usage | Verdict |
|---|---|---|---|---|
| Synchronous large batch job | High | Long blocking | High memory spikes | [X] Bad |
| Asynchronous batched job | Moderate | Short blocking | Controlled memory use | [OK] Good |