Forum: Ruby on Rails Rails app lags after inactivity

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
42292bf8a0acbc98862d9306b501275d?d=identicon&s=25 Daniel Waite (rabbitcreative)
on 2005-12-28 02:59
(Received via mailing list)
Hi all. I have two Rails applications. Each is on its own VPS hosted by
Pipespring (excellent service btw).

My app runs lightning quick - AFTER the first load. If I visit my site
after
a period of inactivity (i.e. no visitors to my site), it takes up to 10
seconds to load that first time. After that I can hop around with no
problems.

Has anyone run into this before? Ideas?

- Rabbit
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 CSN (Guest)
on 2005-12-28 03:53
(Received via mailing list)
Yeah, I've noticed the same thing. But it only happens
- for me anyway - in development mode. The first hit
often times out. After that, it loads about as fast as
production mode. Production mode is always fast.

I don't know why this is. I'm using webbrick for
development mode, and scgi for production mode (can't
remember if scgi in development mode suffers the same
first-hit problem).

csn


--- Rabbit <rabbitblue@gmail.com> wrote:

> problems.
>
> Has anyone run into this before? Ideas?
>
> - Rabbit
> > _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>





__________________________________
Yahoo! for Good - Make a difference this year.
http://brand.yahoo.com/cybergivingweek2005/
42292bf8a0acbc98862d9306b501275d?d=identicon&s=25 Daniel Waite (rabbitcreative)
on 2005-12-28 04:26
(Received via mailing list)
Ah... Yeah the site it seems to happen to most IS in development. I have
another site though that is in production mode and it still tends to lag
if
there's been no activity on it for a while.

But, glad I'm not the only one experiencing this. If I find out what's
causing it I'll post it here. :)

- Rabbit

---
8fd9f26b8f23d49c8a89b63f1279e24f?d=identicon&s=25 Chris Nolan.ca (Guest)
on 2005-12-28 09:51
(Received via mailing list)
I experience this as well and I'm pretty sure it's just swapping on
the server.

If the server doesn't have enough memory to hold all rails processes
at once, then those not getting hit will be sent to disk.  When you
come along to request it, it has to recover that process from disc
and put it back in memory.

If you have shell access on your hosting account you should be able
to view this using top and ps and/or 'free' and 'vmstat'.

Chris Nolan.ca
http://kekova.ca/
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 CSN (Guest)
on 2005-12-28 10:36
(Received via mailing list)
Here's what 'free' shows on my box:

             total       used       free     shared
buffers     cached
Mem:       1029868    1019924       9944          0
 442652     292420
-/+ buffers/cache:     284852     745016
Swap:      2048276     386416    1661860

So, with +/- buffers I should have about 750MB free.
'ps axu|grep ruby' shows:

csn      25060  0.0  0.0 35800    4 pts/3    S
Dec15   4:36 ruby
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/bin/scgi_service
config/scgi.yaml
csn      18359  1.9  4.3 158584 44956 pts/3  D
Dec21 183:17 ruby
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/bin/scgi_service
config/scgi.yaml
csn      30260  0.0  1.5 28372 16208 pts/3   S
Dec24   1:32 ruby ./script/server
csn      26902  0.1  1.2 27248 13344 pts/5   S
00:59   0:08 ruby ./script/server -p 3001

So the webbrick servers are using about 28K/15K
VSZ/RSS each, and the one scgi has 158K/45K. The scgi
servers do seem to grow rather large in size after a
while.

I don't think it's due to swapping, but rather perhaps
something timing out - like webbrick shuts down after
a while and then has to startup. But still, my first
hit after a while almost always results in a timeout
(after about 30 seconds). I dunno...

csn


--- "Chris Nolan.ca" <rubyonrails@chrisnolan.ca>
wrote:

> and put it back in memory.
>
> > hop around with no problems.
> >
> > Has anyone run into this before? Ideas?
> >
> > - Rabbit
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>





__________________________________
Yahoo! for Good - Make a difference this year.
http://brand.yahoo.com/cybergivingweek2005/
132a94ca65959bda6c74fae54bff2425?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2005-12-28 16:40
(Received via mailing list)
I have seen this same behavior on a few sites I made that don't get
much traffic. I'm not exactly sure why the processes 'hibernate' or
whatever they do but the way I have fixed the problem is thus:

	Create a cron job that curl's or wget's a page on your site every 5
minutes and sends the output to /dev/null . This will 'exercise' your
site and keep the processes from having to startup or unswap or
whatever they are doing.

Cheer-

-Ezra Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732
42292bf8a0acbc98862d9306b501275d?d=identicon&s=25 Daniel Waite (rabbitcreative)
on 2006-01-07 23:16
(Received via mailing list)
Sweet. Thanks for the work-around Ezra. :)

---
3e6c3ec4f859de233f38e3b747dee1bb?d=identicon&s=25 Kenneth Parnell (Guest)
on 2006-01-07 23:47
(Received via mailing list)
The lag during development mode has to do with the fact that your pages
are
being pulled from source every time you load them. You best option would
be
to put your app into production mode and work on caching content in
order to
increase speed.

-Kenny
8e44c65ac5b896da534ef2440121c953?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-01-08 03:38
(Received via mailing list)
We are talking about production sites here that run on fcgi and don't
get traffic for large intervals of time. When these apps first get
hit after a period of inactivity it takes a few seconds for the first
page to load. Then after that the performance is great. The fcgi
processes seem to get paged out of memory and take a few seconds to
'wake up'. So this method of using cron and wget just keeps the
fcgi's exercised and in memory instead of paged out to disk.

Cheers-
-Ezra

On Jan 7, 2006, at 2:45 PM, Kenneth Parnell wrote:

>
> every 5
> 509-577-7732
>
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails

-Ezra Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732
This topic is locked and can not be replied to.