ruby-on-railsresque

When does eager loading happen with resque?


I'm fairly new to resque. I recently found out that Rails.application.eager_load defaults to false in rake tasks even if the config is set to true in the environment. I'd like to set config.rake_eager_load = true to rectify this, but I'm not sure what implications this has on my resque jobs. Will resque eager load all classes every time a job is run? Or is it just done once on each deploy?


Solution

  • The classes would all be loaded when the worker process is started, and would remain in memory after that (as new jobs were processed by that worker) until the worker died or was killed (which is generally only on a deploy).

    Main question is why, why shove everything into memory when autoloading works to only load the subset of classes needed for running the jobs you have, and where generally the small performance hit to autoload at worker run time is not a big deal.