WordPress is Ridiculously Slow on Azure Web Apps

I was hired to migrate two WordPress based websites from AWS to Microsoft Azure the other day. Client wanted to use Azure Web Apps AKA Azure Websites for both WordPress sites. I did the migration, but the performance of both sites were horrible after the migration. Turns out there’s an easy fix.

Sites were performing well on AWS. The fact that they were slow after the migration puts me in a bad situation. I owed my client an explanation. It took 70s for homepage to be fully loaded. That was unacceptable. So I ran a test to see what was going on. Time to first byte took almost a minute.

Why TTFB (time to first byte) is too high on Azure Web Apps?

High TTFB means that WordPress is having trouble with backend processing. It’s related to the database in almost all cases. WordPress needs to communicate with MySQL database to generate pages. And if MySQL is taking longer to respond, pages will take longer to create. This will increase TTFB.

I did a little research and found an official word from Microsoft itself about this issue.

If you are developing the site, you can use the Free MySQL database that comes with WordPress install from the Websites Application Gallery. But this is not ideal for a production level site.

We recommend to use to a database that can handle your estimated user traffic from the various other options supported by ClearDB as seen here.

Sites were using the free database option. Adding a Shared Titan database to websites brought page speed down to 10s. But it costs $3.5/mo for each database. Which made it an expensive solution. But however, my client was okay with it.

My Opinion on upgrading to Titan database

I personally find this expensive and unnecessary. The free databases should have resources to handle at least 100 visitors per day. But Azure free databases can’t handle 1 visitor without taking ages to load. So what’s the point of offering it? Just to market your service? So that you can say you have something free to offer? Not cool Microsoft!

Moving on… all SaaS and IaaS services like AWS and Google App Engine are generally expensive. While they have their own advantages, I find it better to buy an unmanaged cloud server and then configuring it with Virtualmin and nginx. It’ll only cost $10/month for a startup site with ability to easily resize the server as needed. And you don’t have to buy new stuff each time you want to set up a new site. You can host multiple websites on the same server. But that’s me. Some people just like to spend more on products thinking it’s better because it’s expensive.

Further Optimization of WordPress on Azure Cloud

10 seconds isn’t a good load time either. The TTFB is still 2 seconds which raises a red flag. But sites weren’t optimized yet. I was able to bring down overall loading time of sites to under 4 seconds after setting up basic caching with a plugin. This can be further optimized using a CDN network to deliver static content, but it adds up to the monthly bill. If you feel like using a CDN, I suggest going with KeyCDN instead of Azure CDN

Final Words

So to sum up… The ridiculously long loading time you experience on WordPress on Microsoft Azure cloud is due to free database that comes with the application. Obviously, Microsoft wants you to pay more if you want to host a production site on Azure Web Apps. It’s a great solution if you have the budget and don’t mind spending few extra bucks. But going with an unmanaged cloud provider is much cheaper than using these SaaS or IaaS services.

Tharindu

Hey!! I'm Tharindu. I'm from Sri Lanka. I'm a part time freelancer and this is my blog where I write about everything I think might be useful to readers. If you read a tutorial here and want to hire me, contact me here.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button