Thursday, December 1, 2016 | Arra Derderian
This past March I wrote a post titled, How to Use Azure BLOB Storage and Azure CDN for Scaling Web Applications. This post was intended to help users speed up their websites by utilizing Azure offerings like BLOB storage and Azure CDN. These features are nice because they allow you to offload requests from your website and serve cached content to users from nodes nearest to them. The other benefit, that I will write about below, is how to architect your Orchard CMS site so you can provide cost savings in Azure.
A typical Orchard CMS setup in Azure will typically consist of a Windows Azure Website and a SQL Azure Database. This is by far the easiest way to stand-up a basic site. Unless, of course, you decide to go with SQL Compact. Then there is no need for SQL Azure. When you setup a site with SQL Azure and a Windows Azure website you are going to need a Standard tier 3 database and a Standard Web App tier 3 as well. Orchard requires a fair amount of database calls out of the box and will require a 7GB RAM web server to run. This is due to the fact he next web app tier down is 3.5GB. This is not enough for a fairly traffic heavy site. It frustrates me that Azure has not shifted some of these thresholds. In my opinion, 3.5GB is not a medium sized server at all. You may be asking yourself, “why there is a need to be on the Standard tier over Basic?” The reason is Azure's backup feature is not present in the Basic tier. This is a necessity in content management type sites because of the Media directory requiring backup. If your site was ever to be lost or corrupted, you would need to restore it from a backup and having your Media directory stored in the website requires you to be backing it up. Secondly, if your credit card expires or you go into delinquency on payments with Microsoft, the first thing they do is tear down your deployments and only preserve your data. This means your webroot would be blown away only leaving any BLOB storage or SQL databases. This would be awful if you lost your entire media director. Here is what you’re looking at for a monthly price point:
SQL Pricing :
App Pricing :
The total is $447.59 a month. This is a tough sell for some smaller businesses that require a content management system and a site that can respond to an average number of requests. In the next section, we will detail how to tweak Orchard's setup and Azure to provide a performant site with some cost savings and even some failsafe’s for site backups.
The first step in providing some cost savings is to figure out what the real differences are in Standard vs. Basic app tiers in Azure. If you review the pricing guide you will see there is not much of a difference other than you don't get automated backups and there is significantly less storage space. Other than that, they are very similar in my opinion. Simply downgrading our tier to Basic level 3 we save almost $75 a month!
You may be asking yourself, “well what do we do about the Media directory not backing up now and having less storage to support it?” Well, that's simple. Orchard CMS can run on BLOB storage as a Media backbone. This is excellent because then your CMS media is stored in BLOB storage which means it can be geo-redundant and easily snapshotted in Azure. You could even sync the Media directory to another storage container should you ever lose it and need to restore. Lastly, it is great because we can now switch on Azure CDN and serve CMS content right from Azure CDN. This improves the speed of our site by offloading image requests to BLOB storage and the CDN as well as serving images off cached servers near our clients. Read this Github thread about how to configure the CDN. To use Orchard CMS BLOB storage you just enable it in the Modules area.
Next we can enable some modules in Orchard that will let us run on lower tiers in Azure for even more cost savings. First, we will enable the Output Cache module and then the SysCache module.
The SysCache module is great because it enables caching at the database level. This greatly reduces the trips to the database. Secondly, the Output Cache will use server memory to cache whole pages in server memory. These modules together are excellent ways to make sure your site performs well. You could even use an external cache via Azure Output Cache or Redis if desired. This reduces server load and database load which lets us drop our tiers from 3 to 2 for more cost savings!
By turning on these modules we have now saved $256.64 a month! Even if we had to move the app tier back up to Basic 3, we would still save $145.04 a month! We can even leverage a scaling technique to handle high traffic times to save money as well. Autoscale is not included in Basic tier, however, you could script something for yourself. Having your Media in BLOB storage makes scaling, and potentially having to redeploy to another data center, much easier.
I hope you take these few simple points into account when architecting your Orchard CMS website in order for you to achieve optimal performance while saving your client some money as well! These are real savings that your client will appreciate!