Speed Up Your Web Site with Microsoft Azure BLOBs


We have all been there before. You have a web application that runs in your data center, and the load the website is generating is increasing. You need to buy more servers and increase your bandwidth to the Internet as well. Every year you find yourself back in the same place, adding servers, increasing bandwidth. The costs of your simple little website keep expanding. In this article we are going to explore how you can leverage Microsoft Azure to ease this burden. You will be able to serve more visitors with the same servers you have today, give them a speedier experience, and reduce your bandwidth usage.

The typical web server farm looks like the following diagram. You have a four web servers (or more) sitting behind a load balancer, receiving requests from the Internet. Your server is handling several jobs. It has to process user requests, fetch data, bind that data to the ASPX view (web forms or MVC) and serve the resulting HTML back. That HTML has URLs to resources your server is hosting, namely images and JavaScript. Serving out this HTML and static resources takes up bandwidth as well. Another challenge is that your users around the world have a poor experience waiting for your static media to be sent from under your desk all the way to Japan.

Figure 1

As traffic to your site grows, so does the demand on your servers and bandwidth. There is a very simple solution to help you out of this ever increasing need for resources. That solutions is cloud computing with Microsoft Azure.

You may not want to or be prepared to move your whole application to the cloud. Perhaps moving the application to the cloud doesn’t make sense in your scenario. The great thing about Azure is that it is meant to be used in pieces; it isn’t an all or nothing scenario.

Imagine keeping your application wherever it is today, under your desk, in your datacenter, or at a hosting provider. All we are going to do is move half of our web server’s responsibilities to the cloud. We are going to move all of our static media to Micrsoft Azure, and have it hosted there.

How can Microsoft Azure help?

Microsoft Azure has three types of storage in the cloud. They are BLOBs, queues and tables. BLOB is an acronym that stands for Binary Large Object, and you might have had reason to work with BLOBs in a relational database like SQL Server. Your experience as a developer was likely terrifying. BLOBs are hard to use in a database, since databases aren’t really made for storing large unstructured pieces of data.

Don’t worry about BLOBs in Microsoft Azure. In Azure they are simply a file system in the cloud. There are a lot of ways to leverage BLOBs in your application, and in this article we are going to look at the simplest of those scenarios, simply hosting you public files in a better place than your server.

Hosting your static media in Microsoft Azure can gain you a lot of benefits. You will quite easily remove a lot of load from your servers. This allows those servers to host even more simultaneous users. This puts off the day when you have to add more servers to your web site. You should track the work your web servers are performing; I think you will see a big spike in the amount of users you can host on one of your servers if they no longer have to respond to the static media requests.

Another benefit is that since the static media is being hosted and served from Microsoft Azure, the client is downloading those files over Microsoft’s bandwidth and not your own. This has two results. The first is that you will have reduced the impact to your own bandwidth. Your web server will still be sending the HTML to the user, but the URLs that point the graphics and JavaScript on your site will point to your BLOBs in Azure, not to files on your server. Their browser will then ask Azure for the images, and not yours. This will lessen that amount of bandwidth that you will need, since most of the bandwidth used by a web site is in transferring the static files, and not the HTML. The user will also not be restricted by the amount of bandwidth you have, since the Azure datacenters have massive pipes to the Internet.

The second benefit is that your users will be able to download more files at the same time. Each browser is limited to downloading only two files per host name. This is an old networking standard that doesn’t really apply to today’s modern networks, but it is still enforced. One cheat many users do is to change the registry of their Windows machine to download more than two files at a time from each host. You can’t rely on your users really doing this to improve the performance of your site.

Many sites now host their static media on the same servers as they used to, but under different web site names to speed up the downloading by browsers. Take a look at some HTML, you might find that all the images on foo.com come from images.foo.com, and that all the JavaScript comes from script.foo.com. These sites do this to speed up their user’s experience. We are going to do the same thing, but move those files to the cloud instead of to another site on the same server.

Figure 2

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read