Web app (WordPress on Linux) is slow (long waiting time for html requests)

Sandi Leonties 66 Reputation points
2021-05-18T10:16:44.737+00:00

Hi,

We have a WP on Linux web app set up in Azure, for which every html requests has a waiting time latency of about 2-3 seconds. As this is a public-facing website, the performance is really important. The website code is really optimised, so the issue is on the server / database. There is no WAG.

I already tried and checked the following, which brought waiting time down from 5sec to 3sec on average:

  • app is always on, uses Http2.0, no ARR cookie
  • I have enabled local cache in App settings
  • App service advisor and database performance recommendation tell me it is all looking good and there are no recommendations to improve performance
  • Memory percentage of App service plan stays constantly at 25% and CPU usage below 10%

However, every html (page requests) waits for at least 2 seconds before loading the html and all media and scripts very fast.

The only thing I can see that I could imporve in the Headers response is that Fast CGI cache is EXPIRED. I am not sure where to turn this on in Azure though.

See below the tipycal timings for html request.

Request Timing
Blocked: 26 ms
DNS Resolution: 0 ms
Connecting: 10 ms
TLS Setup: 16 ms
Sending: 0 ms
Waiting: 2.92 s
Receiving: 0 ms

Can anyone help / suggest anything please?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,930 questions
0 comments No comments
{count} votes

Accepted answer
  1. Grmacjon-MSFT 16,191 Reputation points
    2021-05-19T19:11:16.533+00:00

    Hi @Sandi Leonties

    Thanks for your patience. We apologize for any inconvenience this issue may have caused. It looks like you have done some of the necessary actions to decrease wait time.

    Here are a few additional things you can try:

    • Make sure you're using the latest version of PHP. The latest version of WordPress recommends using PHP 7.4 or greater
      You can change the PHP version from the Azure portal under Setting > Configuration > General Settings

    97887-phpversion.png

    • As you mentioned, switching to PHP FastCGI can also help reduce wait time. To accomplish this you can follow the steps listed in this blog
    • Diagnose if your theme or any extension is slowing down your site. Some themes just like plugins can be poorly written and can slow down your site. Test if your theme is responsible for the long page load times.
    • Lastly, you can try to enforce a persistent database connection between your WP site and your database. Usually, "WordPress does not use a persistent database connection, which means that after a period of idling, the connection to the database will be stopped and when someone visits your app service and it will have to set up a connection to the database, which makes WordPress extremely slow. In order to fix this, you need to login to Advanced Tools (Kudu), navigate to wwwroot in your app service, edit wp-config.php and add the following at the bottom": define('USE_PCONNECT', true);
      define('WP_CACHE', false);

    Hope that helps. If your issue still persists after trying those solutions please let us know so we can investigate further.

    Thanks,
    Grace

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sandi Leonties 66 Reputation points
    2021-05-20T00:18:42.55+00:00

    Hi Grace,

    Thank you very much for your answer. I managed to use a caching plugin on WP which creates static html pages and this seems to solve the long waiting issue. Initially this plugin was not working with LOCAL_CACHE setting enabled in the web app.

    As a note, I think that I am missing something in my Web app, as I would like to update PHP, but I do not have the option available

    98007-image.png

    And also the Process Explorer (to make the Kudu changes mentioned in the blog) seems to be disabled:

    98008-image.png

    Thank you again - will keep digging at it.

    Sandi