Fastcgi_cache sometimes returns statuscode 500

Maxim Dounin mdounin at mdounin.ru
Mon Mar 2 12:45:58 UTC 2015


Hello!

On Mon, Mar 02, 2015 at 06:11:24AM -0500, mastercan wrote:

> Hello,
> 
> Nginx (all versions since September 2014, but at least 1.7.9, 1.7.10)
> sometimes returns HTTP status code 500, when serving pages from
> fastcgi_cache.
> 
> Each time this happens, following conditions hold true:
> *) $upstream_cache_status = HIT (so we don't even hit php-fpm)
> *) $body_bytes_sent = 0 (which is strange, because I've got an error page
> defined for http code 500, that is obviously not sent)
> 
> I've configured an error page for status code 500 which is correctly shown
> on errors from PHP - this was tested for status code 503.
> Nginx seems to have a bug here, I guess? Why would it otherwise return a
> zero bytes size body?
> 
> This happens for about 30-40 requests a day. All other requests (several
> thousand) are correctly returning status code 200. Server load/CPU load is
> very low...
> 
> I've configured fastcgi cache as follows:
> fastcgi_cache_path		/dev/shm/ngxcache levels=1:2 use_temp_path=off
> keys_zone=MYSITE:5M max_size=50M inactive=2h;
> 
> Maybe somebody knows advice?

Try looking into the error log.  When nginx returns 500, it used to 
complain to the error log explaining the reason.

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list