I am hosting a Wordpress instance on GCP Compute Engine (using the Marketplace image). It works great when I directly access the instance IP, and the latency is around 20 ms.
However, in order to make the site secure, I am using a GCP HTTP load balancer in front of the instance. I have pointed my domain to the load balancer.
When I access the Wordpress through the load balancer (either HTTP or HTTPS), I get a few queries that are very good latency times (around 17 ms), but then every 4 or 5 queries, there's a request that takes about 5 seconds. When I access the instance directly, this does not happen.
I enabled the load balancer log, and I observed that the instance is responding slowly every few requests. I tried to set the KeepAlive Apache2 parameter of the instance to 300, but it doesn't make any difference.
What might be the root cause of this? (I am not sure whether it's Wordpress, or the instance, or the load balancer).
Thanks
5.154792 0.080269 0.085232 4.586898 4.585617
Curl against my load balancer IP4.586002 4.581853 0.084445 0.083991 4.581840
Curl against my VM IP0.738966 0.114106 0.116997 0.114877 0.122570
In all three cases, it is the same VM, and it's very consistent when I run it for many more iterations (I didn't have space to paste it all here).