Just yesterday I had to fight a battle reminiscent of Don Quixote…
To keep it technical: a very long running request in a Ruby on Rails application, served by the dynamic duo Apache HTTPd and Mongrel, kept returning an error message to the haples users. Scouring the net for that particular error message generated by the web server led me to a very old Apache bug report, filled up with accounts of what seemed to be the same behaviour I was experiencing. Buried under tens of messages there was a workaround, namely to set a couple of environment variables via SetEnv directive, which did not work (the classical proof of Murphy’s Law).
Time was ticking away and windmills were winning the day…
The problem really seemed to be related to the interaction of Keep-Alive, mod_proxy and an unresponsive Mongrel, too busy with the very long running request… Keep-Alive, where did I hear/read about it? Eureka! Thin to the rescue!
Testing this solution was just a matter of stopping the cluster of Mongrels and starting a couple of Thin instances. Voilà! Everything was working.
What was left to do? Oh, yeah, replace Mongrel in the Capistrano’s recipes too. Nothing much to do here: remove the Mongrel cluster’s recipe and add these few lines:
To be sure that a potential reboot will not leave the web server without its new companions, an “installation” of Thin and an update of Debian’s rc.d was in order.
Simple, short, fast.
Granted, this is just another workaround and the real, right solution is to move that very long running request to a background job; that’s why it’s been put on top of the to-do list.blog comments powered by Disqus