my current Work Stack

  • iOS Objective-C
  • Ruby
  • Mongo
  • Rails/Sinatra
  • jQuery
  • Capistrano
  • Passenger
  • Apache.Nginx
  • Heroku
  • Nodejs
last edited 02.10.2012

here's all my posts so far

02/10 Using the Facebook SDK in an IOS Static Library
04/11 Managing Development or Sometimes work gets in the way of work
12/21 Git Stash: For when your boss|clients|life priorities change
12/09 Picker Fields in Titanium
11/30 An Update on Raphael JS and Charts
10/08 How to make a Native App Form that doesn't suck with Titanium
09/23 Notification Subscriptions in Gowalla
09/21 Developing an API in Rails
08/26 I was promised Event Driven APIs and hoverboards. Where are my hoverboards?
08/14 A Node.js wrapper for Gowalla
08/09 Phusion Passenger Tweaking: Apache stuck in Sending(W)
06/28 HTML 5 is here and breaking old hacks we should have never done!
06/26 Simple PDFkit example in Rails 3
06/23 Raphael.serialize
06/12 Serializing RaphaelJS
06/11 Rails 3 beta4 destroyed my Tie Fighter
05/21 Rails 3 and Shoulda
05/13 Using yaml to configure default options for Paperclip
05/07 It's OK to not be pretentious
04/23 Snippet #1
04/21 I Need Closure
04/16 The Good and Bad of Github
04/08 Fun with Beards, or at least mine

here's some tweets I made

Phusion Passenger Tweaking: Apache stuck in Sending(W)

For some reason I found this information missing from Google searches so I'm going to write one up and wait for Google to index it.

I was having a problem where Apache's process list would slowly begin to fill up with requests stuck in a Sending (or W) state. After my MaxClients was reached, the server would effectively shut down.

Searching for "apache processes stuck in sending W state" yields a whole bunch of people using mod_php and Apache. And it seems that no one ever solved it in a reproducable way. And I'm using Phusion Passenger anyway.

So it seems I had to use my brain. This server:

  • Low traffic
  • lots of virtual hosts
  • No code pushes coincided with the problem.

I couldn't find any other symptoms anywhere. Ruby wasn't getting stuck. The CPU load was low and memory looked normal. All the Apache stats were good.

Then I looked at passenger status.


sudo passenger-status

And I saw only 6 instances. If I ran passenger status again I could see those instances swapping rapidly between one site and all the others.

I found in the Passenger docs, PassengerMaxPoolSize, which defaults to 6. In my passenger.load (Ubuntu config mod file) I added:

1
2
PassengerMaxPoolSize 20
PassengerUseGlobalQueue on

Voila!

It seems one site had starting to get heavy traffic and was constantly pulling instances. But Passenger didn't handle the context switching very well. By giving more pools, that site is able to keep a few all the time so there's no switching.

blog comments powered by Disqus