Obteniendo 500 Internal Server Error, readv () falló (104: Conexión restablecida por par) mientras se lee en sentido ascendente

I'm receiving an HTTP 500 (Internal Server Error) every X calls. I'm not having any type of high CPU load (it's about 5%). I can see this error in the log when it happens:

In /var/log/nginx/error.log

readv() failed (104: Connection reset by peer) while reading upstream

In /var/log/php5-fpm.log

Mar 10 07:21:57.740683 [WARNING] [pool www] child 9413 exited with code 1 after 1117.708602 seconds from start
Mar 10 07:21:57.743140 [NOTICE] [pool www] child 9925 started

Does anyone know what could be happening and how to resolve this situation?

preguntado el 10 de marzo de 12 a las 12:03

¿Está utilizando catch_workers_output in the FPM pool configuration? See also: stackoverflow.com/questions/8677493/… -

2 Respuestas

I had the same issue recently on a server I admin.

Took a long time, at least 2 weeks, and a wasted day at blitz.io before I figured this one out.

Occasionally, any web page on the site would randomly break. Either the first click would have no effect, it would only load part of the page, or most commonly, only the background would be visible. It seemed to occur about 5% of the time.

This issue was especially problematic because it contributed to higher bounce rates and of course, wasted advertising expenses.

For the exact times when the issue occurred, nginx logs revealed only "readv() failed (104: Connection reset by peer) while reading upstream", which implied simply that something had gone wrong in PHP. Google searches revealed no useful solutions to this problem that applied to my case. Even so, blaming PHP didn't make much sense to me, because it seemed to occur after PHP had already sent the output to the browser (we would get the site background, after all).

Since this message was always accompanied by "Error 337 (net::ERR_SPDY_PROTOCOL_ERROR)" in Google Chrome, I wondered if maybe SPDY support was broken in Google Chrome (some Google discussions seemed to suggest Google servers had similar trouble in 2011), or if my version of nginx had broken SPDY support. Upgrading nginx to a version that had SPDY bug fixes didn't help, and everything I read about the Chrome issue suggested it was only an issue with Google servers and only during that period in 2011.

So after spending 6 hours messing with nginx, PHP, and TCP timeouts on my server, I was ready to give up.

Since we had trouble with PHP 5.5's Zend Opcache and PayPal's Merchant SDK in the past, I wondered if maybe Zend Opcache was also related to this. Finally I tried disabling Zend Opcache entirely, and surprisingly, I discovered that I could no longer reproduce the problem.

I read through the Opcache docs hoping to see some mention of another configuration directive I had turned on or didn't that might be contributing to this problem. I really did not want to go back to XCache. After all, Zend has proved to be almost 40% faster at times. Finally I narrowed it down to this in php.ini:

opcache.fast_shutdown = 1

I turned that setting off, and with Zend Opcache turned on, no longer had any ERR_SPDY_PROTOCOL_ERRORs or random connection drops. Thankfully, disabling fast_shutdown did not appear to have any major impact on performance (perhaps 1ms was added).

Respondido 20 ago 14, 21:08

I was experiencing this same issue after upgrading a server from Debian 7 (Wheezy) to Debian 8 (Jessie). On Debian 7 I was using XCache as an opcode cache. When upgrading to Debian 8 and PHP 5.6, the Zend Opcode Cache was also installed and enabled. The two opcode caches went to war.

You can check to see if you have more than one Opcode Cache running by executing

php -v

en una línea de comando.

I removed the php5-xcache package using

apt-get remove php5-xcache --purge

y todo empezó a funcionar de nuevo.

Respondido el 30 de enero de 16 a las 05:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.