{"id":197,"date":"2012-05-10T18:14:59","date_gmt":"2012-05-10T23:14:59","guid":{"rendered":"http:\/\/jamesroberts.name\/blog\/?p=197"},"modified":"2012-05-10T18:22:04","modified_gmt":"2012-05-10T23:22:04","slug":"upstream-timeout-issues-with-nginx-php-fpm-codeigniter-gzip-xdebug-on-dotcloud-resolved","status":"publish","type":"post","link":"https:\/\/jamesroberts.name\/blog\/2012\/05\/10\/upstream-timeout-issues-with-nginx-php-fpm-codeigniter-gzip-xdebug-on-dotcloud-resolved\/","title":{"rendered":"Upstream timeout issues with nginX + php-fpm + CodeIgniter + gzip + xdebug on DotCloud &#8211; [resolved]"},"content":{"rendered":"<p>We have been using DotCloud as our hosting platform for months now, and overall I have been extremely pleased with their service.\u00a0 There were some bumps in the road early on while they were still in their beta phase, but things have been running very smoothly for a few months now.\u00a0 Everything except an uncomfortable number of seemingly random nginX &#8220;upstream timed out (110: Connection timed out) while reading response header from upstream&#8221; errors.<\/p>\n<p>If you want to get what you need and not read the rest of this post, I will make it super simple for you: <strong><\/strong><\/p>\n<h3><strong>If you are using php-fpm,\u00a0<strong>gzip, xdebug <\/strong> and <strong>CodeIgniter<\/strong>, disable xdebug!!!<\/strong><\/h3>\n<p>For anyone who feels like listening to my story, please read on.\u00a0 Not only were these errors unsettling, but they were causing DotCloud&#8217;s load balancer to bounce POST requests\u00a0 back to our servers multiple times because it was getting error responses and assuming nothing was happening on our end.\u00a0 This in turn was causing user input (comments, image uploads, password requests, etc) to be saved (or emails sent) on our application multiple times.\u00a0 Super embarrassing.<\/p>\n<p>After weeks of research and floundering, a DotCloud tech and I finally discovered the issue.\u00a0 There is a known bug with xdebug and ob_gzhandler which was causing our php processes to seg fault.\u00a0 The bug is documented here:<\/p>\n<p><a href=\"http:\/\/grokbase.com\/p\/php\/php-bugs\/0365rtcdgx\/23985-bgs-ob-gzhandler-make-segmentation-fault\">http:\/\/grokbase.com\/p\/php\/php-bugs\/0365rtcdgx\/23985-bgs-ob-gzhandler-make-segmentation-fault<\/a><\/p>\n<p>What was happening was the request was sent to our server, the php process was doing everything it was supposed to, then when CodeIgniter&#8217;s output buffer was being gzipped by ob_gziphandler(), the php process was segmentation faulting and causing nginx to time out waiting for the response from php-fpm.\u00a0 So, while everything was successfully happening in the php script, the output back to the client was failing.<\/p>\n<p>By disabling the xdebug extension in the php configuration, the php processes stopped seg faulting, and everything is happy again!\u00a0 No more Upstream Timeouts! It took a really long time to track this issue down, so I hope this post helps someone =)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have been using DotCloud as our hosting platform for months now, and overall I have been extremely pleased with their service.\u00a0 There were some bumps in the road early on while they were still in their beta phase, but things have been running very smoothly for a few months now.\u00a0 Everything except an uncomfortable [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,1],"tags":[48,51,49,47,53,46,52,54,50],"_links":{"self":[{"href":"https:\/\/jamesroberts.name\/blog\/wp-json\/wp\/v2\/posts\/197"}],"collection":[{"href":"https:\/\/jamesroberts.name\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jamesroberts.name\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jamesroberts.name\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jamesroberts.name\/blog\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":4,"href":"https:\/\/jamesroberts.name\/blog\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"predecessor-version":[{"id":200,"href":"https:\/\/jamesroberts.name\/blog\/wp-json\/wp\/v2\/posts\/197\/revisions\/200"}],"wp:attachment":[{"href":"https:\/\/jamesroberts.name\/blog\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jamesroberts.name\/blog\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jamesroberts.name\/blog\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}