Another day, another disaster with shared hosting. And not this usual gateway-is-down-problem when people are visiting my blog. I started my journey with simple idea – why not WordPress on Azure? After some experiments I got my first results and the picture wasn’t as terrible pricewise as I thought. Here’s my first experiment with WordPress on Azure.
Why I’m considering WordPress on Azure?
You know these special days when you have problems with popular shared hosting and customer support is totally unwilling to help you out? Have you ever pointed with serious questions to n00bies materials that help you same much as as*hole on elbow? Oh, you wanted to check the issue with some technical guy but it’s not possible, at least not on this earth, not in your lifetime? Probably you know… And I know for sure.
So, after I went once again through this crap I started considering let’s say more professional options for WordPress hosting and first thing that came to my mind was Azure. Why? Because it’s so familiar to me. I know about it more than about any other cloud or hosting service. So I started testing it. I knew it may come more expensive than cheap shared hosting but I can be sure I have more control over hosting services and infrastructure and there’s also support that is technical support.
What WordPress on Azure should survive?
Before everything else I tried to understand what my site should survive on peak moments. If it survives peak load then calm times are not a problem anyway. So I took the following screenshot and some previously gathered knowledge about peak hours to make my first estimates.
Looking at active pages we can see that there’s one page that takes most of the load. There are also bunch of other pages but they have less visitis.
Considering that there can be around 120 users at site at same time and considering that average duration of visit is three minutes I can say that 120 means users for current and two previous minutes. When first waves of readers come then pageviews per minute comes around 120. Based on this we can conclude that per minute we get approximately 120/3=40 visitors.
Our goal is to survive 40 page views/minute.
Hosting WordPress on AppService
Perhaps the easiest way to go on Azure is to have App Service with Linux and Azure SQL for MySQL. All we have to do is just set up database, install WordPress and we are good to go.
Well, the doesn’t get even close to shared hosting prices. The biggest obstacle with app service packages is computing power compared to availability of mandatory additional services like support for SSL and domains. As there are other options available I digged into these.
Hosting WordPress on virtual machine
My next idea was having simple virtual machine with everything installed on it. As it’s risky business to take – I’m not an excellent admin guy – I prepared multiple virtual machines to see how much usual peak moments load these VM-s can take.
To give you better understanding about my test virtual machines, here their config:
- B1S size (cheapest of considerable options)
- 1 vCPU
- 1GB RAM
- 4GB temporary storage
- Standard HDD (32GB)
- Roughly 10 EUR/month
It’s the bare minimum to host well optimized WordPress blog and stay in 40 requests/minute threshold.
Great discount! Actually you can get way cheaper price by Microsoft if you with 3 year reserved payment option. It gives you ~47% of savings (5.30 EUR/month). Same option with Azure hybrid benefit gives ~72% savings (2.79 EUR/month). Find out more from Azure virtual machines pricing page.
The most interesting experiments I made with these two virtual machines. Yes, I had more machines but these were the two on the different ends of line.
|Azure Database for MySQL
Those who know WordPress and small virtual machines probably already guessed what happened to VM1 – yeah, it turned to black hole. We can see what’s going on on events horizon, we know that something is going on inside black hole but we have not much idea what’s there.
To understand better what happens under load I monitored VM1 and made the following findings:
- When WordPress makes per every request all needed queries to database then VM runs out from memory.
- Main explosion happens at the moment when Linux starts using swap.
- MySQL doesn’t recover from crash.
- It takes up to 1:30 hours for VM to get responsive again.
The following screenshot shows what happened to monitoring when B1S went down. I made multiple experiments with it and I even got disk operations per second to hit 500. It’s more than it is allowed for this small virtual machine. For almost 40 minutes disk didn’t respond and I’m sure there was pretty normal hell going on in my little virtual machine.
With VM5 things were better. It survived all the load but with one trick: 25 EUR/month for MySQL hosting. Is it good or bad trick? Depends on how we look at it. If we are up to cheapest price then it’s bad. But if we think that we just hired professional DBA with 25 EUR/mo then things look really positive again.
What’s the best for WordPress on Azure?
It’s time now to compare the options we have and analyze pros and cons. The numbers here are rough estimates based on my experiments with this blog. The prices contain also rough estimates for blob storage, static IP and traffic.
|App Service with local MySQL
|App Service with Azure Database for MySQL
|Virtual machine with local content and local MySQL
|Virtual machine with blob storage and local MySQL
|Virtual machine with blob storage and hosted MySQL
My results lead me to these conclusions:
- App Service is convenient and needs less work to get everything set up and running. It’s kind of Rolls-Royce of hosting because with production packages we get also automatic scaling and other interesting features. The downside is the price – with reliable set of services we pay at least 63 EUR/mo.
- Virtual machine with all-local setup is cheapest and if we move client-side content to blob storage we pay few euros per month more. It’s cheapest for public blog that has to survive some peak moments but be aware that whole infrastructure is your own responsibility. But hey, it’s still 15 EUR/mo.
- Virtual machine with blob storage and hosted MySQL is best of the both worlds. It’s like a golden way between there worlds. On one hand we get virtual machine to manage but on the other hand we have data and content safe on other Azure services. We have just on VM to keep alive, manage and backup. Our site survives more load than this blog post expected. During my tests it survived around 80 page loads per minute. It’s twice more than expected.
Questions and answers
As I have held this topic up in private conversations I have already got some questions asked more than once. I will provide you with my answers. Of course, all kind of discussion is still welcome.
- Why not containers?
I know what they are and how they work but for this journey it’s not my cup of tea. I want to have minimal number of moving parts as possible and right now I prefer to go with small virtual machines. If they prove to be the stable option then I will probably stay with these.
- How do you do disaster recovery?
My WordPress on Azure journey is still in starting phase but right now I will plan to go with WordPress own backup tools and scripts that publish backups to blob storage. I don’t add plugins to my blog very often and I don’t use many plugins. I’m sure that most of time my virtual machine(s) doesn’t have any troubles and if they have I can restore them from image and WordPress backup. Content and data are not in virtual machine.
- The prices are abnormal to me – why even bother?
I want to be sure on few things. I want to have more control over my infrastructure than shared hosting provides and I really want to know how different components and services perform. I also want to be sure that I have quality tech support who can really help me in case of problems. Additionally – if me needs for resources grow I want to be able to react fast without switching from one package to another and waiting days while it happens.
- But why virtual machines?
This is the beginning of my journey. I prefer virtual machines right now as they cheaper than other options. I have previous experiences with more complex content publishing solutions and architectures. I know that scaling, fail over, resiliency and disaster recovery are not simple things to do. As prices grow fastest with App Service based on my n00bish experiments then I feel more safe with virtual machines. I have already more preparation experiments done and virtual machines seem to be perfect match for me.
- What were the major performance boosts during experiments?
- You said it’s the beginning of journey. What’s the next step?
The next step is actually already done and it is about high-availability. I have simple but working topology in place and I have also measurements done. Just have to find a time to form this information as next blog post.
- What will be the final solution?
I hope it will be something affordable, stable and bulletproof. I’m not sure if it happens but I’m working to get there and chances are good I will get there. To keep up interest I have one interesting number to tell: 2 page views per second.
There are many ways how to host WordPress on Azure and depending on services the price comes lower or higher. The more convenience and safety we need the more we will pay. The less we pay the more we have to work on infrastructure and WordPress. What’s optimal depends on needs of specific WordPress site. For my blog it would be optimal to go with last option and I don’t have to take care of MySQL and disk storage by my own. I just write my blog posts, I publish these to WordPress and continue with whatever I did before. I can be sure that in case of any troubles I can ask for support – be it officials or other kind MVP-s who survive my stupid questions with not many mental damages or be it other friends from IT. The best thing is – I know the limits of solution, it’s easy to monitor and what’s most important – it’s easy to scale if needed.