Score:0

Wordpress Slowness Behind GCP HTTP Load Balancer

in flag

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

John Hanley avatar
cn flag
1) Unless you are sitting next to the VM, a latency of 20 ms would not cover the Internet latencies. 2) WordPress executes a fair amount of PHP just to deliver a simple page. There is not enough information in your question to even begin to solve your problem. When one request takes a lot more time than other requests, I first look at the database and resources the database requires. Next, I would review the plugins to make sure that one of them is not the culprit.
tocas619 avatar
in flag
@JohnHanley This is the curl for all three options. Curl against my domain: `5.154792 0.080269 0.085232 4.586898 4.585617` Curl against my load balancer IP `4.586002 4.581853 0.084445 0.083991 4.581840` Curl against my VM IP `0.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).
John Hanley avatar
cn flag
I have no idea what those numbers are reporting. Edit your question and put the data with a header there. Include the command and where you are running the command.
tocas619 avatar
in flag
@JohnHanley Thank you for your help. I fixed it now by replacing the load balancer. See my answer below.
Score:0
us flag

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.

tocas619 avatar
in flag
I enabled the CDN, but it didn't help. I have only one VM, so there are no RPCs. When I ran the curl command, I still get long latencies for the total time for many requests through the LB. Here is one line of results from the curl command (running through LB IP): `time_namelookup: 0.000485time_connect: 0.016699time_appconnect: 0.000000time_pretransfer: 0.016785time_redirect: 0.000000time_starttransfer: 9.077449———time_total: 9.077659`. Running it directly through the instance has no problems.
Score:0
in flag

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 :)

toxaq avatar
de flag
I actually had an identical problem and this is the only place I've found it described. The solution for me, found on a random downvoted stackoverflow question, was to remove https from the load balancer forwarding to the VM instance group (I'd selected both http and https for no sensible reason).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.