views:

231

answers:

2

I have a Rails + Apache2 + Postgres + Passenger application running in production mode in OSX Snow Leopard. The application serves as a data warehouse for another application in the cloud so I'm constantly getting API calls to my OSX production build.

After a recent reboot, I'm finding a ton of httpd processes stacking up and eventually requiring an apache reboot. I haven't changed any settings, everything was running fine before. Any ideas on the best way to troubleshoot this?


$ ps -ef|grep httpd
    0  6203     1   0   0:00.20 ??         0:00.47 /usr/sbin/httpd -D FOREGROUND
   70  6222  6203   0   0:00.05 ??         0:00.11 /usr/sbin/httpd -D FOREGROUND
   70  6224  6203   0   0:00.31 ??         0:00.50 /usr/sbin/httpd -D FOREGROUND
   70  6233  6203   0   0:00.05 ??         0:00.10 /usr/sbin/httpd -D FOREGROUND
   70  6234  6203   0   0:00.43 ??         0:00.64 /usr/sbin/httpd -D FOREGROUND
   70  6243  6203   0   0:00.02 ??         0:00.03 /usr/sbin/httpd -D FOREGROUND
   70  6319  6203   0   0:00.08 ??         0:00.16 /usr/sbin/httpd -D FOREGROUND
   70  6334  6203   0   0:00.02 ??         0:00.05 /usr/sbin/httpd -D FOREGROUND
   70  6469  6203   0   0:00.04 ??         0:00.08 /usr/sbin/httpd -D FOREGROUND
   70  6487  6203   0   0:00.36 ??         0:00.48 /usr/sbin/httpd -D FOREGROUND
   70  6593  6203   0   0:00.36 ??         0:00.48 /usr/sbin/httpd -D FOREGROUND
   70  6709  6203   0   0:00.04 ??         0:00.08 /usr/sbin/httpd -D FOREGROUND
   70  6718  6203   0   0:00.04 ??         0:00.10 /usr/sbin/httpd -D FOREGROUND
   70  6834  6203   0   0:00.01 ??         0:00.03 /usr/sbin/httpd -D FOREGROUND
   70  6852  6203   0   0:00.00 ??         0:00.00 /usr/sbin/httpd -D FOREGROUND
   70  6853  6203   0   0:00.01 ??         0:00.02 /usr/sbin/httpd -D FOREGROUND

A: 

have you installed another apache web server or is it the one already installed?

Shripad K
this is the only one installed. maybe requests are timing out? i'm not seeing any errors in production log, apache error log or access logs though. my passenger-status looks pretty full:<pre><code>--- General information ---max = 6count = 6active = 5inactive = 1Waiting on global queue: 0--- Domains --- PID: 8810 Sessions: 0 Processed: 238 PID: 9443 Sessions: 3 Processed: 49 PID: 7902 Sessions: 3 Processed: 2600 PID: 8416 Sessions: 4 Processed: 212 PID: 9253 Sessions: 4 Processed: 234 PID: 8438 Sessions: 4 Processed: 227</code></pre>
LeoAlmighty
ok. from your info the total apps running are 6. I guess you should consider increasing the PassengerMaxPoolSize. Also consider turning the PassengerHighPerformance, PassengerUseGlobalQueue option on. Due to fair load balancing if there is one long running request then the other requests won't be processed. I guess its a good thing to take a look at the docs and see what suits you the best.http://www.modrails.com/documentation/Users%20guide.html
Shripad K
A: 

Ok this is what i could figure out from my setup. Everytime i run an app 2 httpd processes spawn. I currently have 3 apps running and hence have 6 httpd processes. It has to do with passenger. It is tightly integrated with apache.

This is what i get:

 0    20     1   0   0:00.32 ??         0:01.48 /usr/sbin/httpd -D FOREGROUND
70   104    20   0   0:00.01 ??         0:00.01 /usr/sbin/httpd -D FOREGROUND
70   264    20   0   0:00.01 ??         0:00.01 /usr/sbin/httpd -D FOREGROUND
70   265    20   0   0:00.01 ??         0:00.01 /usr/sbin/httpd -D FOREGROUND
70   271    20   0   0:00.01 ??         0:00.01 /usr/sbin/httpd -D FOREGROUND
70   275    20   0   0:00.01 ??         0:00.01 /usr/sbin/httpd -D FOREGROUND
70   277    20   0   0:00.00 ??         0:00.00 /usr/sbin/httpd -D FOREGROUND
70   278    20   0   0:00.00 ??         0:00.00 /usr/sbin/httpd -D FOREGROUND

I don't suppose its a problem. Guessing by your process list you have around 7 apps running in the cloud if i am right.

According to the Phusion Passenger docs:


PassengerMaxPoolSize

The maximum number of Ruby on Rails or Rack application instances that may be simultaneously active. A larger number results in higher memory usage, but improved ability to handle concurrent HTTP clients.

The optimal value depends on your system’s hardware and the server’s average load. You should experiment with different values. But generally speaking, the value should be at least equal to the number of CPUs (or CPU cores) that you have. If your system has 2 GB of RAM, then we recommend a value of 30. If your system is a Virtual Private Server (VPS) and has about 256 MB RAM, and is also running other services such as MySQL, then we recommend a value of 2.

If you find that your server is unable to handle the load on your Rails/Rack websites (i.e. running out of memory) then you should lower this value. (Though if your sites are really that popular, then you should strongly consider upgrading your hardware or getting more servers.)

This option may only occur once, in the global server configuration. The default value is 6.


You mentioned this: "eventually requiring an apache reboot". So does any of your rails app freeze after a point?

Shripad K
yeah, after a certain point, all the rails apps freeze and stop responding to any http requests. I haven't changed any settings in the last 24hrs and it seems to be running fine now, at least no lock ups and pile up of httpd processes. i'll need to monitor traffic and see if that's the cause, then tweak passenger settings accordingly. thanks. :)
LeoAlmighty
Good to hear that everything is fine for now. :)
Shripad K