Apache2 Server Huge response time

I am hosting my website in a Gcloud Compute Engine instance in the 'us-central1-a' zone and I'm trying to access the website from Spain, but its response time is about 20s.

I believe it's a problem with my apache2 config, and I've also checked and dnslookup is disabled in /etc/apache2/apache2.conf.

Any suggestions?

Thanks!


Solution 1:

I don't think network latency is causing a big problem here because hitting a different URL such as time curl -v https://bruto.com.es/robots.txt results in a 0.4 second response. (It's a 404 but that doesn't matter much. Real static files such as https://bruto.com.es/wp-content/themes/palmplaza/assets/js/jquery.stellar.min.js also respond in 0.4 seconds.)

That also mostly rules out Apache because it will be hitting the same vhost and same config.

It's quite interesting to see that the response comes back in chunks with a 3 second gap between each one when running curl -v https://bruto.com.es/. The first chunk starts after 7 - 8 seconds.

My guess would be that the slowness is happening within PHP. This could be a pause when doing something like connecting to a database or running a query (possibly caused by a database in a different zone to the webserver) or it could be something unique to GCE like CPU rationing. If you can ssh on to the server, running sudo strace -T -tt -p [PID] on the Apache or PHP process you might be able to narrow it down further.