Dispatch.fcgi using a lot of CPU seconds

I run a Ruby on Rails application which isn’t complex; it simply involves users posting images and commenting on them.

I noticed lately I am using a lot more CPU seconds than I used to, even though the number of visitors I get a day is basically the same and most of the changes to the application over time have been trivial. I finally looked at the itemized resources analysis, and while most of it looks normal, it seems like dispatch.fcgi is using large chunks of CPU at once. Here is an excerpt:

2.33 cpu 10748k mem 0 io dispatch.fcgi *
0.04 cpu 10748k mem 0 io dispatch.fcgi *
17.68 cpu 10748k mem 0 io dispatch.fcgi
39.39 cpu 10742k mem 0 io dispatch.fcgi
0.03 cpu 10742k mem 0 io dispatch.fcgi *
1.99 cpu 10742k mem 0 io dispatch.fcgi *

I can’t think of any aspect of my actual application that would cause this. The most CPU-intensive part of the application is presumably thumbnailing, which just calls ImageMagick. There are no indications of problems when I run the application locally or even when I browse the site. I don’t know whether or not CPU seconds translate 1:1 to realtime seconds or not. I do know that php5.cgi always seems to be under 1 second no matter what.

So, uh, is this normal? Just going through the log and adding up numbers, these larger spurts account for about ~300 CPU seconds, which is the vast majority of them considering I’m at ~400 a day. I know 400 CPU seconds isn’t a whole lot, but I’m just thinking ahead to when my site might not be so small. I only get about 250 unique visitors a day at the moment. So, imagine I’m getting a thousand unique visitors a day and that 400 seconds becomes two thousand or roughly 30 CPU minutes.

Am I freaking out over nothing?

If your site is still peppy, then I wouldn’t worry about it. Support will nag you if it becomes a problem.

Out of curiosity, what is that RoR app? I like to see what’s out there.


I would have posted it but it’s NSFW, and since it’s user-drive, some of the content is really pretty offensive. If it’s truly difficult to offend you, then http://eleochan.org I think I was going to get hired for a programming gig once until the employer actually visited my site.

Anyway, I was just trying to solve this issue before support nags me because I’m over my (invisible) CPU limits. Since Ruby is so slow I figure I will have to find myself a VPS earlier than someone running a PHP forum, but for now I’m trying to make the most out of what I have :slight_smile:

Process CPU seconds user machine count average
dispatch.fcgi 1169.2600 93.478% 4.872% 144 8.120

Come on, tell me I’m not in or nearing danger zone.

That’s Rails and my app facing a measley 800-something unique visitors…