We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Xavier Noria - The Rails Boot Process - Rails World 2024
Dive into Rails' boot sequence with Xavier Noria as he explores config files, initializers, and lazy loading improvements in Rails 8, enhancing app performance and startup.
-
Rails boot process consists of three main config files:
config/boot.rb
,config/environment.rb
, andconfig/application.rb
-
The boot process follows a specific order:
- Load config/boot.rb to set up Bundler
- Set up autoloaders (once and main)
- Load Rails and gem dependencies
- Load initializers in topological order
- Build middleware stack
- Load routes (lazy in Rails 8)
-
Rails applications are built on three key concepts:
- Railties (base class for extending Rails)
- Engines (like mini Rails apps with their own MVC)
- Applications (subclass of Rails::Engine)
-
Initializers are fundamental to the boot process:
- Over 300 initializers in a typical Rails app
- Run in topological order
- Can be configured with before/after hooks
- Come from both the framework and application code
-
Lazy loading improvements in Rails 8:
- Routes are lazy loaded by default
- Constants managed by autoloaders load on demand
- Better boot performance through delayed loading
-
Key boot process features:
- Configuration hooks for customization
- Inheritance-based setup through Rails::Application
- Environment-specific configuration precedence
- Separate autoloaders for application and framework code
-
Most Rails commands require full application boot, with few exceptions like
rails stats
-
The boot process is distinct from server launch - booting means getting the application ready for use, while launching the server is a separate step