This post covers running WordPress as an Azure App Service.
In October of 2018, I was tasked with helping a client move their current .NET based marketing websites over to WordPress. This was so they could have their marketing team make updates to the sites leveraging the front end editing power of the Beaver Builder Framework. The only prerequisite was that it needed to run on the Azure App Service Platform.
I built the first site on my development server which runs on Digital Ocean. Once I was ready for them to start testing, we spun up an Azure App Service platform running WordPress. In case you’re wondering what an
App Service is:
“Azure App Service enables you to build and host web apps, mobile backends, and RESTful APIs in the programming language of your choice without managing infrastructure.”https://docs.microsoft.com/en-us/azure/app-service/
The App service platform is very powerful and I have had great experiences with using them in the past, so I expected the WordPress experience to be on par with my past experiences. Using the Azure App Service for WordPress requires setting up a separate MySQL Database using Azure Database for MySQL This setup allow for enterprise-grade hosting with a SLA to match, which I thought would make the site super-fast, since the server resources for the site would not have to deal with hosting the MySQL server, but it turned out I was quite wrong about that.
We setup the App Service and MySQL database using relativity powerful setting for a single site.
As soon as I moved the site to Azure, I noticed an huge performance issue. Each request made to the site would take 5-10 seconds to complete, which was a huge test of my patience.
It took about a month of diagnosing and experimentation to figure out what the issue.The first indication of the issue was the Time To First Byte (TTFB) which was anywhere from 3-8 SECONDS!
On the same site, running on Digital Ocean, the TTFB was 286 milliseconds or 0.286 Seconds, so that was clearly the issue!
So what was causing this huge disparity of time to First Byte?
SO what was causing this huge disparity of time to First Byte?
To start with, I used the P3 Performance Profiler Plugin.
P3 told me the site was running 160 queries for each page to load on the front end.
I then ran a test of the PHP and MySQL performance using the PHP/MySQL CPU performance statistics Plugin, which showed the On Azure, the site was only able to run 20 MySQL queries per second (QPS).
Suddenly the 8 second load time made sense, when you do the math: 160 queries per visit / 20 per second = 8 seconds
On my Digital Ocean development server, running 1 GB of RAM and 1 CPU core, I was getting 556 QPS, which was clearly the issue.
Naturally, I thought we had some issue in our configuration of the App Service and the MySQL database, so I opened a ticket with Azure Support. The support rep was very helpful (they always seem to be), finally came back with the following response after giving me
I was grateful for the honesty, but also very disappointed that there was the huge bottleneck in running SQL queries. Since WordPress has about a 30% market share of internet sites, so I am shocked Azure doesn’t have a solid
What To Do If You Have to Run WordPress On Azure?
If you use a caching plugin, then the front end of the site loads pretty well, but as soon as you do any work on the admin end of things, the performance goes back down, and running updates takes a very long time.
If you have a requirement of hosting on Azure, then there a good deal of Virtual Machine (VM) images for WordPress websites, which would not have the same issue as the App Services do.
If you want to run multiple sites, you can get a Plesk VM.
Plesk is a management platform for WordPress (and many other web apps and services). I tried Plesk for a few weeks and it worked great, but it does have a steep learning curve.
The simplest way to host on Azure, would be to setup an Azure VM, and then run Server Pilot to manage the WordPress Apps. Server Pilot is an incredibly simple and performant WordPress management solution
I am hopeful that I can update this post in a few months that the issues have been fixed, but until that point, I have to recommend avoiding WordPress hosting on Azure App Services.
If you’re having similar issues feel free to contact me if you have any questions about this issue.