# Rails Initialization

**URL:** <https://www.ruby-forum.com/t/rails-initialization/105448>\
**Category:** Rails\
**Created:** [May 30, 2007, 3:13am UTC](https://www.ruby-forum.com/t/rails-initialization/105448 "2007-05-30T03:13:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bc8723/32.png) [@lee](https://www.ruby-forum.com/u/lee)\
**Post date:** [May 30, 2007, 3:13am UTC](https://www.ruby-forum.com/t/rails-initialization/105448/1 "2007-05-30T03:13:06Z")

</div>

I have labored under the (possibly naive) misconception that a Rails  
app initialized and loaded on every request. Now I’ve found hints  
that the core application loads and stays available for later  
requests? How is this possible? I thought that the Ruby interpretter  
loads everything into its own little happy process. Does Rails wait  
around for requests on a port or something to keep it connected to the  
webserver?

I’m working on understanding Rails Initialization and the full process  
of the framework.

Thanks guys!

Lee Hericks

---

<div class="post-metadata">

**Author:** ![lee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bc8723/32.png) [@lee](https://www.ruby-forum.com/u/lee)\
**Post date:** [May 30, 2007, 4:01am UTC](https://www.ruby-forum.com/t/rails-initialization/105448/2 "2007-05-30T04:01:11Z")

</div>

The Mongrel or WEBrick web servers do in fact stay running between  
requests. In development model WEBrick will reload modified files. I  
have yet to determine if it provides any ordering of those files or  
just reloads the files on top of whatever was there. So far I have  
not seen any indication that patches from one class are lost when  
reloading another file so it is not simply just reloading files on top  
of the current version.

Michael

---

<div class="post-metadata">

**Author:** ![lee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bc8723/32.png) [@lee](https://www.ruby-forum.com/u/lee)\
**Post date:** [May 30, 2007, 5:02am UTC](https://www.ruby-forum.com/t/rails-initialization/105448/3 "2007-05-30T05:02:15Z")

</div>

A first request comes in. The rails app hasn’t been loaded yet.

The dispatcher sees that nothing is defined, so it loads  
environment.rb

environment.rb loads boot.rb

boot.rb sees that the initializer is not present, so it loads  
initialize.rb

The whole framework boots up to life.

Routing processes the request and a response is sent back to browser.

NOW…how is that Ruby environment persisted and able to handle the  
next request sent to the web server? Assume Lighty. Lighty gets a  
request and maybe passes it off to Mongrel. Mongrel is written in  
Ruby and mongrels keep running. Is that why the next request given to  
the mongrel loads the dispatcher, which sees RAILS\_ROOT and skips  
loading the environment, and processes the request?

If so, what does that mean if you are not using Mongrel? What if you  
are simply using lighttpd? What keeps running the Rails-loaded Ruby  
environment?

Lee Hericks
