Gateway timeout with haproxy on long requests

I was trying to make a payment using PayPal SOAP API today and on a standard rubyworks installation (Apache --> HAProxy --> Mongrels), I was getting a Gateway Timeout Error. On checking the logs, I found out that the payment was in fact going through and rails was generating the thanks page too. My first doubt was that mod_proxy was timing out while waiting for a response. I tried to increase ProxyTimeout to 120 secs but it had not effect. I then tried to send the request directly to port 3001 (haproxy port in rubyworks) and I still saw the timeout happening. On sending the request to a mongrel directly (I tried on port 3002), the payment went smoothly and the thanks page was rendered. I tried to browse around and found this page where they mention that by default, if mongrel does not respond back in 30 secs, haproxy times it out. The setting can be increased by simply changing the variable srvtimeout to a larger number (say 120000 for 120 secs) in the configuration file /etc/rails/haproxy.conf

blog comments powered by Disqus