In a previous post we looked at the different ways of using HTML5 to get videos playing on a web site. It’s easy enough to use the <video> tag to link to video files but if these files are hosted on the same server as the rest of the site then there’s a big performance risk if a video suddenly goes viral and thousands of people are trying to download it at once. Hosting videos in the cloud using something like Amazon Web Services is a cheap and scalable solution for storing large files and making sure your site doesn’t grind to a halt during big spikes in traffic.
Benefits of the cloud
Traditional web hosting companies usually offer businesses a fixed price package with the main variables being the amount of storage space and bandwidth allowance. Bandwidth is the amount of data that can be transferred (uploaded or downloaded) to the hosting server. A typical allowance might be 100GB per month so if you’re hosting a top quality 100MB video file then you’re only allowed 1,000 downloads of that video until you start paying out excess charges to the hosting company (not counting any other bandwidth hits like web pages, images or documents!).
Cloud storage sidesteps the bandwidth issue by being completely scalable. You only pay for the bandwidth you use. If only a handful of people are accessing your video then costs will be very low but if a video suddenly gets very popular then the Cloud service can quickly meet demand with costs rising to cover the increased bandwidth usage. Your web site’s performance is unaffected while the Cloud ensures that your video files are playing back smoothly and permanently accessible to people anywhere in the world.
Get up and running with Amazon cloud
The most popular option for cloud hosting would be to use Amazon Web Services (AWS) which is very easy to setup and inexpensive. We’ve used it specifically for hosting video files and found it perfect for our needs.
To make the most of AWS you first need to set-up an S3 bucket which is essentially a storage area for your files. You can upload files to this bucket via the S3 console but I’ve found this to be a bit flakey, especially with large file sizes using limited upload speeds. A client like Transmit seems to perform better. Once your files are uploaded make sure that the properties are set correctly in the S3 console. I’ve found you sometimes have to manually set the Content-Type, to video/mp4 for example, and the permissions so that everyone can open or download the file.
Finally, you need to configure a CloudFront service to distribute your uploaded files. Most distributions for HTML5 video will be set to ‘Download’, but the other option is ‘Streaming’ which is useful for Flash video (flv) files played within a Flash movie. The difference is that downloaded videos are saved from the cloud and onto the computer it’s being viewed on, whereas a streaming video isn’t saved, apart from a small ‘buffer’ used to ensure smooth playback. Streaming videos can also switch between low and high quality versions depending on the user’s bandwidth.
CloudFront will give you a url to access your video from so just add that to your <video> tag as previously discussed and it’s ready to rock!
As Cloud storage becomes more widely used we should see plenty of other hosting companies offering Cloud-based solutions. Rackspace already have loads of options with their Open Cloud solutions but Amazon currently remains the easiest to implement and is a great way to get videos in the Cloud.