If you’ve been keeping up with the blog, you’ve heard me talking a lot about the “cloud” lately. It is a term that seems to be on much of the tech world’s lips, and for good reason. The cloud is a mystical place where anything can happen, full of unicorns and leprechauns.
Apple’s doing it with iCloud. Google’s doing it with ChromeOS. Amazon has been doing it for some time.
Yet, for all that, the average consumer still doesn’t really understand what, exactly, the cloud is. Having just gotten Start Google Plus up and running on its own cloud setup, I’ve come to understand the whole idea a lot better.
A Brief Primer on the Internet
Most of you probably have a pretty decent idea about how the internet generally works, but for those who don’t, here’s the ultra simple version.
Whenever you load a webpage (from your internet browser on your laptop, from your phone, or even when your mail app on your phone checks the mail) you are simply connecting to another computer in the world that has the information you are looking for. To explain how your device finds that computer, the analogy of street addresses is commonly used. An “IP Address” is a street address for the internet, and in essence it lets us find any other computer.
I’m going to take this analogy one step further to explain why the cloud is so great…
A Shared Server is like an Apartment
As I said, all websites reside on a computer. Most websites reside on a computer shared my many other websites, called a shared server. Your typical website does not get anywhere near enough traffic for this to become a problem.
But, just like with an apartment, there are limitations. If you run out of space, there are not many ways you can upgrade. If you start covertly building into the walls, chances are you’ll end up commandeering your neighbor’s closet (and you’ll get caught).
Likewise, there are a lot of different things that may limit a website:
- In an apartment you can’t throw big parties because there is not enough parking and space for people to arrive. Likewise, on servers, you need enough bandwidth to send all the data back and forth to the people connecting.
- You only have so much space for yourself in an apartment. On a server, hard drive space (to store the website) RAM (used when the website needs to be sent back to a user) etc. are all limited quantities.
These are just some of the bottlenecks that can cause a server to be insufficient (slow). When it becomes apparent that one or more of them are in short supply, it is time to upgrade…
A Dedicated Host is like a House
If you live in a nice suburban house, chances are you have the space to yourself (and your family). A dedicated server is a computer for just your website (or, possibly, multiple websites). Being exclusive to your needs, it has a number of advantages.
First, you have the permission to do more things. If you want to repaint the walls or dig a hole (change certain properties of the server) you do not need to ask the neighbors and the landlord. It is your house (server). You can just do it.
Moreover, you probably have room for growth. If you start to run out of RAM or hard disk space, you can generally upgrade your hard drive or RAM just like you would on your computer at home.
I switched Start Google Plus over to a dedicated server just a few days after launch. It worked well for a while, but four days later I no longer had any room for growth. I had packed everything as tightly as I could (written good code) and upgraded everything I could.
It was time for the cloud.
The Cloud is like a Mansion
Most people would like to live in a mansion. You have all the space you could possibly want. If you feel cramped, you just build a whole new house on your property.
The cloud is like this. When a website runs on the cloud, it is living in a mansion – a huge plot of land on which it can build as many houses as it wants.
The basic way that the cloud works is to allow you to take the computers you need. That’s it. When you need more capacity, you take another computer. When you don’t need it any more, you give it back and it gets released into the wild.
This effectively means that if Start Google Plus suddenly triples in size right this very instant, it will build three times more houses in the next 5-10 minutes in order to accommodate the load. All of a sudden, new servers are online and the traffic is not a problem.
But there are complications with living in such a big, luxurious mansion. Imagine if in your mansion you had a cook, a chauffeur, a stable master etc… but each of them lived in their own house and could never travel to any other house. So now in our mansion we have many houses, each with a single occupant or staff member.
All of a sudden, the complexity of management goes through the roof. When a new visitor arrives, there is no longer just one person to talk to. You need a doorman (or two) to greet the guests and direct them to the right place. You need someone to do the bookkeeping, because you don’t want each of the staff keeping their own separate records.
Of course, when the traffic starts to become too large, your staff needs to actually know that it is time to build a new house. So, a simple democratic system is used. If any of the staff (servers) decides that he is too busy, he can vote to build more houses and hire more staff. If enough of the staff vote as much, then the houses are built and the staff hired.
And that is basically it! The mansion gets bigger and smaller as needed. Yet, to the outside world, it is still a single location that resides at a single address.
A Few Takeaways
When traffic spikes, the cloud can handle it – but if it spikes too fast, it may not be able to react perfectly in time. Each new server takes a few minutes to boot up, after all. During this time the site may be inaccessible.
The management complexity and cost of the cloud is large. Practices that were fine on a single computer, from a programming perspective, are no longer usable. For example, you cannot store data on one computer and expect that it will be accessible later because the visitor (on the next visit) may actually visit a different computer. For you computer programmers, this means you have to use a single centralized dedicated database, not local file storage.
One good practice I have learned is to start with the smallest (cheapest) available options on the cloud (the slowest servers) and try to get everything to work with them. Optimize as much as possible, and only update to better computers when it becomes necessary.
Ultimately, the cloud is a great way to have a scalable website or service. But it has its own challenges in implementation.