ruby on rails - What's the performance impact of disabling eager_load in production.rb? -


my rails 4.1 app connects second, non-primary server via ssh backend jobs. consequently, when rails app restarts daily, ssh connection needs live/up (rather second, non-primary server needs live/up), otherwise the app crashes. due eager loading default being set true in production.rb (config.eager_load = true).

i'm tempted break dependency disabling eager loads, i'm not able find information on performance impact. so, questions are...

1) if eager_load set false, simple slow down app's startup time, or app eagerly load resources first time hit?

3) if eager_load turned off, degree impact performance off app (more subjective question)?

2) model performs ssh connection under folder app\models\legacy. instead of changing eager_load false, can folder excluded eager loaded resources? if so, how? believe need edit config.autoload_paths += dir[rails.root.join('app', 'models', '{**/}')] not entirely sure.

production.rb:

  # eager load code on boot. eager loads of rails ,   # application in memory, allowing both thread web servers   # , relying on copy on write perform better.   # rake tasks automatically ignore option performance.   config.eager_load = true 

setting eager_load=false speed up app's startup, because loading deferred until necessary.

however, penalty app use more memory (which scarce server resource). suspect may run threading bugs if use multithreaded server (e.g. puma) eager_load=false.

since rails automatically includes app/* directories in eager load paths, can't think of easy way exclude app/models/legacy while eager-loading else.

instead, move contents of app/models/legacy e.g. legacy/ @ root of project , add autoload_paths:

config.autoload_paths += %w( #{config.root}/legacy ) 

now rails still able find files, won't eagerly loaded in production.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -