User Uploaded Images – Blank Post – Connection reset by peer / FastCGI: incomplete headers

To give a little background, I have a website that permits users to upload images. WordPress is used as a content management system and the posts are immediately published with the image inserted as the featured image of the post. From that point the images are displayed in a gallery style format. For nearly a year I had the website on a GoDaddy shared server and had no issue with the images uploaded. As the site has grown I have transferred the website to an Amazon instance. On the instance is the corresponding MySQL Database, which while I know is frowned upon for it should be set up as a separate instance, reduces costs for the moment. The web / database server is on a c3.xlarge instance. Unfortunately, about 50% of the time now, when users upload images they receive an error [Internal Server Error] and a blank post is created, which is subsequently included within the galleries. Obviously, this is problematic as the gallery is filled with blank images, which detracts from the user experience. The blank post image is devoid of a featured image, when I look into the backend of WordPress, and the post is categorized as Uncategorized. At this point I believe that problem stems from a server setting and communication with the MySQL database, but I am grasping at straws. I have scoured the error logs at around the time of the blank posts and the only thing I have found is as follows:

[Sat Jun 14 19:23:51 2014] [error] [client xxx] (104)Connection reset by peer: FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: read failed, referer: http://example.com/upload/
[Sat Jun 14 19:23:51 2014] [error] [client xxx] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi", referer: http://example.com/upload/
[Sat Jun 14 19:27:51 2014] [error] [client xxx] (104)Connection reset by peer: FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: read failed, referer: http://example.com/upload/
[Sat Jun 14 19:27:51 2014] [error] [client xxx] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi", referer: http://example.com/upload/

In researching the issue I have found that many people have suggested increasing the php memory limit to combat this problem. Recently I increase memory_limit from 128M to 256M and even 512M, but this unfortunately did not have any noticeable impact. Any ideas?

Related posts

Leave a Reply

1 comment

  1. You believe wrong. The problem is – as so often with quickly written software – that the upload routine you have is not robust enough.

    You can see that clearly that in case of an error blank pictures are inserted. Instead the error condition should be treated accurately and no image should be inserted.

    This is very important, because the exact part that needs to care about the upload handling needs to do the error reporting so you better understand what goes wrong here.

    For the FastCGI specific problems, I assume they just say that the application hangs so the FCGI handler disconnects the backend – I’m not so fluent with Amazon.

    So I’d say this is more a time-out issue than a memory issue.

    As you should touch the whole upload workflow anyway due to insufficient error handling, I would perhaps think about limiting the file-upload size for a moment while you’re making the procedure more robust.