Sonntag, Jänner 11, 2009

switching to passenger

Though I am working with passenger for a while now, I just had new projects which started from the scratch using passenger. This week I switched my first mongrel based rails app to passenger. The idea was using passengers GlobalQueue option to optimize overall perfomance. One of the major mongrel drawbacks is its port based queues. If you have long running requests all others in the queue for that port have to wait. Thats different if you have just one global queue which doesnt pass request to busy processes.

While this works well as expected there are some minor modifications in the request header because the proxy has gone. For instance the webapplication read the calling ip address with the HTTP_X_FORWARDED_FOR header info. This is empty now with passenger.

So instead of calling

request.env['HTTP_X_FORWARDED_FOR']

I had to use

request.env['REMOTE_ADDR']
which has just the same info, the calling IP.