So, I''ve deployed my first rails app, however I''m the only one hitting it for now. I''ve noticed that the first time I hit the app after some long period, it takes a really long time to respond (2-3 seconds). After that, it''s very fast. At first, I thought it might be my VPS "waking up" from some sleep state, but Rails does log the long load time (log below). My app just uses the database for login/user auth. Otherwise, it serves up pages on the filesystem in textile and renders them as HTML. There is no explicit caching done by me, and the filesystem/ textile/rendering is all hand-rolled (so there''s no caching done implicitly). What are some things I should look for to understand why this happens? log of two sequential requests for the same page: Processing WikiPagesController#show (for 98.218.223.189 at 2009-08-12 20:16:41) [GET] Parameters: {"id"=>"MainPage"} Rendering template within layouts/application Rendering wiki_pages/show User Columns (1.3ms) SHOW FIELDS FROM `users` User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) LIMIT 1 Repopulating the stop words Rendered common/_header (16.7ms) Rendered common/_nav (4.4ms) Rendered common/_search (2.4ms) Rendered common/_footer (0.6ms) Completed in 2422ms (View: 134, DB: 2) | 200 OK [http://myserver.com/ wiki_pages/MainPage] Processing WikiPagesController#show (for 98.218.223.189 at 2009-08-12 20:17:04) [GET] Parameters: {"id"=>"MainPage"} Rendering template within layouts/application Rendering wiki_pages/show User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) LIMIT 1 Rendered common/_header (10.9ms) Rendered common/_nav (1.6ms) Rendered common/_search (1.7ms) Rendered common/_footer (0.2ms) Completed in 138ms (View: 53, DB: 0) | 200 OK [http://myserver.com.com/ wiki_pages/MainPage]
Are you using Passenger? Jamey On Wed, Aug 12, 2009 at 8:22 PM, davetron5000<davetron5000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > So, I''ve deployed my first rails app, however I''m the only one hitting > it for now. > > I''ve noticed that the first time I hit the app after some long period, > it takes a really long time to respond (2-3 seconds). After that, > it''s very fast. > > At first, I thought it might be my VPS "waking up" from some sleep > state, but Rails does log the long load time (log below). > > My app just uses the database for login/user auth. Otherwise, it > serves up pages on the filesystem in textile and renders them as > HTML. There is no explicit caching done by me, and the filesystem/ > textile/rendering is all hand-rolled (so there''s no caching done > implicitly). > > What are some things I should look for to understand why this happens? > > log of two sequential requests for the same page: > > Processing WikiPagesController#show (for 98.218.223.189 at 2009-08-12 > 20:16:41) [GET] > Parameters: {"id"=>"MainPage"} > Rendering template within layouts/application > Rendering wiki_pages/show > User Columns (1.3ms) SHOW FIELDS FROM `users` > User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) > LIMIT 1 > Repopulating the stop words > Rendered common/_header (16.7ms) > Rendered common/_nav (4.4ms) > Rendered common/_search (2.4ms) > Rendered common/_footer (0.6ms) > Completed in 2422ms (View: 134, DB: 2) | 200 OK [http://myserver.com/ > wiki_pages/MainPage] > > > Processing WikiPagesController#show (for 98.218.223.189 at 2009-08-12 > 20:17:04) [GET] > Parameters: {"id"=>"MainPage"} > Rendering template within layouts/application > Rendering wiki_pages/show > User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) > LIMIT 1 > Rendered common/_header (10.9ms) > Rendered common/_nav (1.6ms) > Rendered common/_search (1.7ms) > Rendered common/_footer (0.2ms) > Completed in 138ms (View: 53, DB: 0) | 200 OK [http://myserver.com.com/ > wiki_pages/MainPage] > > > > >
Yes, I''m using passenger with a config like so: passenger.conf LoadModule passenger_module /usr/share/passenger/ext/apache2/ mod_passenger.so PassengerRoot /usr/share/passenger PassengerRuby /usr/bin/ruby PassengerLogLevel 2 httpd.conf RailsBaseURI /my_app The passenger.conf was configured by my hosting provider and the (one line of) configuration for Apache was via me reading the passenger configuration Dave On Aug 12, 8:37 pm, Jamey Cribbs <jcri...-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote:> Are you using Passenger? > > Jamey > > On Wed, Aug 12, 2009 at 8:22 PM, davetron5000<davetron5...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > So, I''ve deployed my first rails app, however I''m the only one hitting > > it for now. > > > I''ve noticed that the first time I hit the app after some long period, > > it takes a really long time to respond (2-3 seconds). After that, > > it''s very fast. > > > At first, I thought it might be my VPS "waking up" from some sleep > > state, but Rails does log the long load time (log below). > > > My app just uses the database for login/user auth. Otherwise, it > > serves up pages on the filesystem in textile and renders them as > > HTML. There is no explicit caching done by me, and the filesystem/ > > textile/rendering is all hand-rolled (so there''s no caching done > > implicitly). > > > What are some things I should look for to understand why this happens? > > > log of two sequential requests for the same page: > > > Processing WikiPagesController#show (for 98.218.223.189 at 2009-08-12 > > 20:16:41) [GET] > > Parameters: {"id"=>"MainPage"} > > Rendering template within layouts/application > > Rendering wiki_pages/show > > User Columns (1.3ms) SHOW FIELDS FROM `users` > > User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) > > LIMIT 1 > > Repopulating the stop words > > Rendered common/_header (16.7ms) > > Rendered common/_nav (4.4ms) > > Rendered common/_search (2.4ms) > > Rendered common/_footer (0.6ms) > > Completed in 2422ms (View: 134, DB: 2) | 200 OK [http://myserver.com/ > > wiki_pages/MainPage] > > > Processing WikiPagesController#show (for 98.218.223.189 at 2009-08-12 > > 20:17:04) [GET] > > Parameters: {"id"=>"MainPage"} > > Rendering template within layouts/application > > Rendering wiki_pages/show > > User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) > > LIMIT 1 > > Rendered common/_header (10.9ms) > > Rendered common/_nav (1.6ms) > > Rendered common/_search (1.7ms) > > Rendered common/_footer (0.2ms) > > Completed in 138ms (View: 53, DB: 0) | 200 OK [http://myserver.com.com/ > > wiki_pages/MainPage]
Things may have changed, but AFAIK, passenger does go to sleep after a period of no http activity on your site. What I ususally do is create a cron job that runs every 5 minutes and just hits the web server, something like: wget http://localhost or whatever. This ensures that passenger keeps ruby loaded in memory and the app is no longer sluggish on that first hit. HTH, Jamey On Wed, Aug 12, 2009 at 9:50 PM, davetron5000<davetron5000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Yes, I''m using passenger with a config like so: > > passenger.conf > > LoadModule passenger_module /usr/share/passenger/ext/apache2/ > mod_passenger.so > PassengerRoot /usr/share/passenger > PassengerRuby /usr/bin/ruby > PassengerLogLevel 2 > > httpd.conf > > RailsBaseURI /my_app > > The passenger.conf was configured by my hosting provider and the (one > line of) configuration for Apache was via me reading the passenger > configuration > > Dave > > On Aug 12, 8:37 pm, Jamey Cribbs <jcri...-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote: >> Are you using Passenger? >> >> Jamey >> >> On Wed, Aug 12, 2009 at 8:22 PM, davetron5000<davetron5...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > So, I''ve deployed my first rails app, however I''m the only one hitting >> > it for now. >> >> > I''ve noticed that the first time I hit the app after some long period, >> > it takes a really long time to respond (2-3 seconds). After that, >> > it''s very fast. >> >> > At first, I thought it might be my VPS "waking up" from some sleep >> > state, but Rails does log the long load time (log below). >> >> > My app just uses the database for login/user auth. Otherwise, it >> > serves up pages on the filesystem in textile and renders them as >> > HTML. There is no explicit caching done by me, and the filesystem/ >> > textile/rendering is all hand-rolled (so there''s no caching done >> > implicitly). >> >> > What are some things I should look for to understand why this happens? >> >> > log of two sequential requests for the same page: >> >> > Processing WikiPagesController#show (for 98.218.223.189 at 2009-08-12 >> > 20:16:41) [GET] >> > Parameters: {"id"=>"MainPage"} >> > Rendering template within layouts/application >> > Rendering wiki_pages/show >> > User Columns (1.3ms) SHOW FIELDS FROM `users` >> > User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) >> > LIMIT 1 >> > Repopulating the stop words >> > Rendered common/_header (16.7ms) >> > Rendered common/_nav (4.4ms) >> > Rendered common/_search (2.4ms) >> > Rendered common/_footer (0.6ms) >> > Completed in 2422ms (View: 134, DB: 2) | 200 OK [http://myserver.com/ >> > wiki_pages/MainPage] >> >> > Processing WikiPagesController#show (for 98.218.223.189 at 2009-08-12 >> > 20:17:04) [GET] >> > Parameters: {"id"=>"MainPage"} >> > Rendering template within layouts/application >> > Rendering wiki_pages/show >> > User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) >> > LIMIT 1 >> > Rendered common/_header (10.9ms) >> > Rendered common/_nav (1.6ms) >> > Rendered common/_search (1.7ms) >> > Rendered common/_footer (0.2ms) >> > Completed in 138ms (View: 53, DB: 0) | 200 OK [http://myserver.com.com/ >> > wiki_pages/MainPage] > > > >
Passenger will shut down it''s rails instances after a certain amount of inactivity. So when you hit the site after a long absence it takes a second or two load up the rails instance (just like ./script/console takes a second or two). After that it''s up and you don''t have that lag. You''re hosting provider is probably doing this intentionally so it doesn''t have a lot of rails processes sitting around doing nothing. On Aug 12, 2009, at 6:50 PM, davetron5000 wrote:> > Yes, I''m using passenger with a config like so: > > passenger.conf > > LoadModule passenger_module /usr/share/passenger/ext/apache2/ > mod_passenger.so > PassengerRoot /usr/share/passenger > PassengerRuby /usr/bin/ruby > PassengerLogLevel 2 > > httpd.conf > > RailsBaseURI /my_app > > The passenger.conf was configured by my hosting provider and the (one > line of) configuration for Apache was via me reading the passenger > configuration > > Dave > > On Aug 12, 8:37 pm, Jamey Cribbs <jcri...-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote: >> Are you using Passenger? >> >> Jamey >> >> On Wed, Aug 12, 2009 at 8:22 PM, >> davetron5000<davetron5...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> So, I''ve deployed my first rails app, however I''m the only one >>> hitting >>> it for now. >> >>> I''ve noticed that the first time I hit the app after some long >>> period, >>> it takes a really long time to respond (2-3 seconds). After that, >>> it''s very fast. >> >>> At first, I thought it might be my VPS "waking up" from some sleep >>> state, but Rails does log the long load time (log below). >> >>> My app just uses the database for login/user auth. Otherwise, it >>> serves up pages on the filesystem in textile and renders them as >>> HTML. There is no explicit caching done by me, and the filesystem/ >>> textile/rendering is all hand-rolled (so there''s no caching done >>> implicitly). >> >>> What are some things I should look for to understand why this >>> happens? >> >>> log of two sequential requests for the same page: >> >>> Processing WikiPagesController#show (for 98.218.223.189 at >>> 2009-08-12 >>> 20:16:41) [GET] >>> Parameters: {"id"=>"MainPage"} >>> Rendering template within layouts/application >>> Rendering wiki_pages/show >>> User Columns (1.3ms) SHOW FIELDS FROM `users` >>> User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) >>> LIMIT 1 >>> Repopulating the stop words >>> Rendered common/_header (16.7ms) >>> Rendered common/_nav (4.4ms) >>> Rendered common/_search (2.4ms) >>> Rendered common/_footer (0.6ms) >>> Completed in 2422ms (View: 134, DB: 2) | 200 OK [http:// >>> myserver.com/ >>> wiki_pages/MainPage] >> >>> Processing WikiPagesController#show (for 98.218.223.189 at >>> 2009-08-12 >>> 20:17:04) [GET] >>> Parameters: {"id"=>"MainPage"} >>> Rendering template within layouts/application >>> Rendering wiki_pages/show >>> User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) >>> LIMIT 1 >>> Rendered common/_header (10.9ms) >>> Rendered common/_nav (1.6ms) >>> Rendered common/_search (1.7ms) >>> Rendered common/_footer (0.2ms) >>> Completed in 138ms (View: 53, DB: 0) | 200 OK [http://myserver.com.com/ >>> wiki_pages/MainPage] > >
Looks like this will solve the problem: http://www.modrails.com/documentation/Users%20guide.html#PassengerPoolIdleTime Just ran into this issue on my VPS. - JK. On Thu, Aug 13, 2009 at 12:08 PM, Philip Hallstrom<philip-LSG90OXdqQE@public.gmane.org> wrote:> > Passenger will shut down it''s rails instances after a certain amount > of inactivity. So when you hit the site after a long absence it takes > a second or two load up the rails instance (just like ./script/console > takes a second or two). After that it''s up and you don''t have that lag. > > You''re hosting provider is probably doing this intentionally so it > doesn''t have a lot of rails processes sitting around doing nothing. > > > On Aug 12, 2009, at 6:50 PM, davetron5000 wrote: > >> >> Yes, I''m using passenger with a config like so: >> >> passenger.conf >> >> LoadModule passenger_module /usr/share/passenger/ext/apache2/ >> mod_passenger.so >> PassengerRoot /usr/share/passenger >> PassengerRuby /usr/bin/ruby >> PassengerLogLevel 2 >> >> httpd.conf >> >> RailsBaseURI /my_app >> >> The passenger.conf was configured by my hosting provider and the (one >> line of) configuration for Apache was via me reading the passenger >> configuration >> >> Dave >> >> On Aug 12, 8:37 pm, Jamey Cribbs <jcri...-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote: >>> Are you using Passenger? >>> >>> Jamey >>> >>> On Wed, Aug 12, 2009 at 8:22 PM, >>> davetron5000<davetron5...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> So, I''ve deployed my first rails app, however I''m the only one >>>> hitting >>>> it for now. >>> >>>> I''ve noticed that the first time I hit the app after some long >>>> period, >>>> it takes a really long time to respond (2-3 seconds). After that, >>>> it''s very fast. >>> >>>> At first, I thought it might be my VPS "waking up" from some sleep >>>> state, but Rails does log the long load time (log below). >>> >>>> My app just uses the database for login/user auth. Otherwise, it >>>> serves up pages on the filesystem in textile and renders them as >>>> HTML. There is no explicit caching done by me, and the filesystem/ >>>> textile/rendering is all hand-rolled (so there''s no caching done >>>> implicitly). >>> >>>> What are some things I should look for to understand why this >>>> happens? >>> >>>> log of two sequential requests for the same page: >>> >>>> Processing WikiPagesController#show (for 98.218.223.189 at >>>> 2009-08-12 >>>> 20:16:41) [GET] >>>> Parameters: {"id"=>"MainPage"} >>>> Rendering template within layouts/application >>>> Rendering wiki_pages/show >>>> User Columns (1.3ms) SHOW FIELDS FROM `users` >>>> User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) >>>> LIMIT 1 >>>> Repopulating the stop words >>>> Rendered common/_header (16.7ms) >>>> Rendered common/_nav (4.4ms) >>>> Rendered common/_search (2.4ms) >>>> Rendered common/_footer (0.6ms) >>>> Completed in 2422ms (View: 134, DB: 2) | 200 OK [http:// >>>> myserver.com/ >>>> wiki_pages/MainPage] >>> >>>> Processing WikiPagesController#show (for 98.218.223.189 at >>>> 2009-08-12 >>>> 20:17:04) [GET] >>>> Parameters: {"id"=>"MainPage"} >>>> Rendering template within layouts/application >>>> Rendering wiki_pages/show >>>> User Load (0.4ms) SELECT * FROM `users` WHERE (`users`.`id` = 4) >>>> LIMIT 1 >>>> Rendered common/_header (10.9ms) >>>> Rendered common/_nav (1.6ms) >>>> Rendered common/_search (1.7ms) >>>> Rendered common/_footer (0.2ms) >>>> Completed in 138ms (View: 53, DB: 0) | 200 OK [http://myserver.com.com/ >>>> wiki_pages/MainPage] >> > > > > > >