Search code examples
phpapachemagento-1.9varnish-4

Unusual intermittent page load


I am running into a problem and don't even know how to begin to diagnose it.

My current server setup is as follows;

Ubuntu 16.04, Apache 2.4, PHP7.0-FPM, Mysql 5.6 and Varnish 4.

Apache listens on port 443 and Varnish listens on Port 80. Requests to port 443 are ProxyPass to Varnish on port 80 as follows (vhost snippet).

ProxyPreserveHost On
ProxyPass / http://127.0.0.1:80/
RequestHeader set X-Forwarded-Port "443"
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set Ssl-Offloaded 1 

Varnish then serves static content and passes everything else to Apache on port 8080.

PHP requests are handled by php-fpm and is set as follows (vhost snippet).

<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
    SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"
</FilesMatch>

For some reason, when Varnish is serving requests, every now and again when surfing the site, particularly when adding a product to the cart, the page load will hang for almost perfectly 60 seconds before continuing to load. In most cases it loads very fast. But when it does hang, the apache, varnish, php-fpm, mysql, including php-fpm slow logs and mysql slow logs do not show anything erroneous.

I can not seem to reproduce the error when Varnish is disabled (piping all requests).

How can I see what is holding up the request or process?

I am stumped as to where to look next?


Solution

  • Turns out the issue was a bug related to piping post requests pre varnish version 4.1.3.

    Since Ubuntu 16.04 repo has an outdated Varnish 4.1.1 we were affected by the bug. Upgrading to the latest Varnish 4.1.6 solved the problem for us.

    https://github.com/varnishcache/varnish-cache/issues/1806