Penny Pinching on Microsoft Azure (updated)

Cloud Computing is becoming a very interesting platform for Startups and small development teams who usually do not have much capital to invest in infrastructure and management. Cloud Computing is usually considered a cheap, quick and easy way to spin up (and down) resources such as websites or virtual machines. However, you may still be spending a lot more than necessary should you not try to make your system “Cloud efficient”.

There has been many articles on the Internet on saving money on the Cloud. As Cloud resources are usually billed by usage, trying to optimize your app can save you a lot of money. If you are using Microsoft Azure, I recommend reading some blog posts from Scott Hanselman on the “Penny pinching” topic:

http://www.hanselman.com/blog/PinchingPenniesWhenScalingInTheCloud.aspx
http://www.hanselman.com/blog/PennyPinchingVideoMovingAnAzureWebsiteBetweenDataCenters.aspx
http://www.hanselman.com/blog/PennyPinchingVideoMovingMyWebsitesImagesToTheAzureCDNAndUsingACustomDomain.aspx
http://www.hanselman.com/blog/PennyPinchingInTheCloudHowToRunATwoDayVirtualConferenceFor10.aspx
http://www.hanselman.com/blog/PennyPinchingInTheCloudEnablingNewRelicPerformanceMonitoringOnWindowsAzureWebsites.aspx

In this blog post I will also share some of my experience with saving money on Microsoft Azure through out my team’s projects. And please let me know in the comments if you have even better ways to save money on the Cloud!

Use SQL Azure efficiently

Migrate to Table Storage

My team used to create a MS SQL database for each of our app when we still rented the whole MSSQL hosting service for a fixed monthly price (around 5 USD/month). Then it cost us a lot more when we moved the same architecture to Microsoft Azure. One database (less than 1GB in size) cost 5-10 USD/month, which is not very expensive, but for small teams like us and with so many small databases, it cost a lot.

Since we did not use all the nifty features of SQL Azure on all our databases, we realized that we were wasting a lot of money, especially on those small or quite static databases (even relatively unchanged databases with the size of 1-5MB cost 5 USD/month). We revised our apps, and decided to move most of them to Table Storage, which costs only around 10 cent/month for 1TB. That means we can save 5-10 USD/month for every database that we can move from SQL Azure to Table Storage.

Using Table Storage, we lost many features that are normally available on relational databases such as automatic indexing or arbitrary column querying, but simple storing and querying by keys are still enough for not so critical applications such as bug tracking or storing transit and travel data of a city.

You may also consider using MySQL (e.g. CloudDb) or other NoSQL databases (e.g. MongoDb), which can also be created and managed directly inside Azure portal. However, there price is quite similar to SQL Azure offering.

Switch to the new Basic Plan

There are 3 new service tiers for SQL Azure: Basic, Standard and Premium (they are currently at 50% discount for preview prices). You can also consider moving your Web tier databases to the new Basic tier, which cost around 5 USD/month now (which cost 3 USD/month during preview, and probably 6 USD/month after GA).

Using VM to host your databases

If you have a lot of small databases (e.g. for all your small mobile apps and games), provisioning a VM to host all of them may also be a good choice. Of course, as any other IAAS solution, you will have to spend more time to manage the virtual machine, making sure that they are running well all the time.

Be aware of the new limits in Notification Hub

Notification Hub is a very convenient way to send push notifications. However, it does not integrate a user-based push mechanism at the moment. Instead, we have to use tags to send push to devices of a particular user, which means we need 1 tag for each user ID. It was ok with the old pricing scheme, but the current one limits 3000 tags for Free and Basic tiers (10 USD/month). If your application has more than 3000 users (which also means it needs more than 3000 tags), you will have to move to Standard tier, which costs a whooping 200 USD/month.

I really hope that Microsoft will have some solutions soon to smooth out the transition from Basic to Standard tier. Otherwise, we will have to consider implementing our own push services, and leaving Notification Hub for the moment.

Consider scheduled WebJob to replace Scheduler

Update: It seems that you cannot create multiple scheduled WebJobs (and in turn multiple scheduler job collections) in one region now. I will have to check again later and update this section with more accurate information.

If you have been using Azure Scheduler for a while, you will notice that you can create only 1 free job collection, which can contain maximum 5 jobs; anything more than that requires at least a Standard tier Scheduler collection, which costs 20 USD/month.

Generally, we need some very simple triggers to a URL every day or at most every hours to perform very quick tasks, so we do not want to spend 20 USD/month here. Fortunately, there is recently another solution: if you are using Azure Website, you can create scheduled WebJobs to perform the same task as Scheduler services. In fact, creating scheduled WebJobs also creates a free Scheduler job collection to trigger the execution of the job, but it seems that there is no limit at the moment.

Note: WebJob is now still in preview, so I am not sure if the pricing will change when it is officially released.

Conclusion

The Cloud is an interesting place where you can customize your monthly bill to your heart’s content. It’s worth spending some time to explore all available services and their prices that your Cloud provider offers before designing your awesome new app. You should also be aware that saving some small amount of money may cost you much time later on when scaling up (or out) your solution, and I think there is no perfect recipe for every one on the Cloud.

Finally, Microsoft Azure have a very clean and convenient page for you to see all their offering: http://azure.microsoft.com/pricing

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.