1

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

2 Answers2

0

To check and optimize latency, consider the scenario mentioned below:

  1. To optimize latency for your Load Balancer, I would suggest you enable the Cloud CDN option. Cloud CDN reduces latency by serving assets directly at Google's network edge. In the Backend Configuration section of Load Balancer, you can select the Enable Cloud CDN checkbox. For detailed instructions, see the Cloud CDN how-to guides.

  2. To reduce latency inside your applications, examine any remote procedure calls (RPCs) that communicate between VMs. This latency typically occurs when applications communicate between tiers or services. Tools such as Cloud Trace can help you decrease latency caused by application-serving requests. For further information, you can check here.

If still issue persist, then share the following details to get more clarity on your issue:

  1. HTTP load balancer configuration i.e. health checks, backends, front ends, firewall rules etc.

  2. Supporting load balancer logs- backend and frontend latency, MTR from client to LB and LB to backend.

  3. To check request and response time to both server IP and LB IP, run the following command:

            curl -w "@curl-format.txt" -o /dev/null -s http://<LB IP/server IP>
    

Note: To create a ‘curl-format.txt’ file, go through the timing-details-with-curl document.

0

I spent many days trying to fix this, and today I just decided to go the old route and make a new load balancer. The new load balancer works like a charm. It was exactly the same configuration, so I'm not sure what happened, but there's that :)