top of page

Insights

Writer's pictureMax Awan

An Understanding of Cloud Computing

Updated: May 12, 2022


What is the cloud?

To the non tech-savvy person, what does ‘the cloud’ mean? When thinking of uploading files to the cloud, the common person does not care where that file goes, they think of that file as being up in the ether and accessible everywhere - stored away in thin air until its next called upon.


What does this really mean? What is the cloud? And what actually happens when you upload a photo or your favourite song to the cloud?


Well, in short, that file is being stored on someone else's computer (otherwise known as a server). This computer would typically be one of many belonging to a big company (think Amazon, Google and Microsoft)


An image of a big cloud server farm

Here’s an example of a big cloud server farm.


In this picture, racks upon racks of computers are used for ‘cloud’ purposes.


So when you next upload a family photo to the ‘cloud’, you should be aware, you’re actually most likely just storing that picture on a computer, most likely belonging to a big tech company.


Depending on the website you’re uploading the photo to, it could just as easily be a random stranger's computer. That random stranger will then be able to do what he likes with your family photo or whatever else you upload.


This brings us onto what a website or web server actually is.


What is a web server or website?

A web server is someone’s computer. Even the computer you’re using right now, or even your phone, which is really just a mini computer, can be used to host a website.


NGINX logo

An image with the following logos: php, XAMPP, Apache, Eclipse

When starting as a web developer, you typically start by making a web application which runs ‘locally’.


‘Locally’ means that you are running it on your own computer. You can then see that website in your web browser (Chrome, Firefox etc.) But no one else can access and see your local site from their computer, so it’s not quite a website yet.


How to host a simple website yourself?

To run a website on your computer, a free downloadable tool like NGINX or Apache can be used. Even with a simple one page html file on your computer, you can run Apache and expose it to the internet.


Then, anyone with the public IP address of your computer will be able to connect to it. Or if you buy a domain name, you can set that up so when they go to {insert your cool domain name here}.co.uk it will point to the web page being hosted on your computer!


If you’re developing an app locally using a popular web programming language & framework (like python & Django, ruby & ruby on rails etc.) then NGINX or Apache2 can be configured to expose your app to the internet just as well!


Why use a cloud provider or web hosting service?

If your own computer can host a website then why would you pay someone else to host your website?


Well first off, if you don't mind leaving your computer on full time then you could very well host it yourself but then there are other issues like security which could also have an effect on your decision. By opening up ports on your computer to the world, you’re also risking all your personal stuff on your own computer!

For many people, the deciding factors are that your computer would need to handle the many requests made by people trying to look at your website and also would have to be kept turned on constantly.


If it’s a hobby website which you’re not expecting many people to look at, that’s one thing.


However, If you’re planning on this being a professional website expecting lots of users and traffic then your personal computer may very well not cut the mustard.


For a professional site, it may very well need to scale to handle large amounts of traffic and requests. Even if, hypothetically, you had a really powerful computer at home, issues can happen which can cause it to go down.


Power cuts, windows updates or even your partner unplugging your pc for her hair straighteners can cause unexpected downtime!


This is where the latest cloud offerings can help.


Cloud Offerings and EC2 Instances (AWS)

Rather than using your own computer to host a website, you can rent an EC2 ‘instance’ (EC2 stands for Elastic Compute Cloud) from Amazon or similar from Google or Microsoft Azure.


In essence, an EC2 instance is a computer (henceforth ‘instance’) which you can connect to and have power to do what you want with.


In reality, although what you’re renting behaves and acts like a computer, it’s actually a ‘virtual machine’ which is really just using some of the resources of a computer. Or as techies call it: ‘compute capacity’


There are loads of options to configure that instance. If you want to run things on it which are very intensive, like processing videos or machine learning stuff then you can rent a much beefier instance or you can hire a ‘micro’ instance with the bare minimum needed to run a website.


Similarly, depending on where your visitors are expected to be located you can rent the instance in a location of your choice. Amazon, for example, has server farms located all around the globe.


Here’s a map of distributed instance locations around the world


A map of distributed instances of Amazon server farm locations around the world

You can even commit to renting an instance for a longer period of time (e.g. 2 years or so) and get it cheaper (this is called a reserved instance).


Or you can get it for dirt cheap using ‘spot’ instances. This is when you pay less for spare space on servers which hasn’t been hired at full price. This is similar to how shipping companies quite often use spare space in the haul on commercial planes.


There is a risk with ‘spot’ instances though that your instance can be interrupted when that spare space is claimed.


Alternatively, many companies actually offer free hosting too but these often come with a catch and don’t typically have the same level of service or quality of offerings that the big cloud providers (Amazon, Google, Microsoft) do.


Serverless

Now for the juicy stuff. There has recently been a bit of a hype in the ‘cloud’ world regarding ‘serverless’ computing. This has come about from the flexibility of compute capacity.


Similarly to the Zipcar model of having and paying for a car just when you need it, you can pay for the resources running your website only when they’re needed (when someone visits the website).

An image of a ZipCar

‘Serverless’ is, as you might be thinking, a bit of a misnomer though as it would be a bit like calling Zipcar ‘car-less’. You are still renting the resources of a server but the crucial difference is that you’re only paying for it when it's needed.


As expected, just as Zipcar is lots cheaper than paying for a car full time, serverless is way cheaper than renting a website full time.


Serverless also allows you to avoid dealing with servers etc and focus purely on your app!

The AWS Fargate logo

AWS Fargate is one of the Amazon offerings which allows you to run your app serverlessly.


(If you’re interested in how to do that technically, you’ll need to dockerize your app and put it on AWS first)


From the perspective of someone visiting the website, the main difference is that it might take a couple of seconds longer to load the first page they’re looking at.


Scaling your application - the need for multiple servers

As mentioned before, having your website running on one computer, even if it’s one run by amazon etc, can have potential issues. If that computer goes down then so does your website.


Similarly, as your business grows and you need to be able to handle lots more people looking at your website and making requests to it, you’ll either need a beefier server or, what is better practice, is to run your website across multiple servers.


An image of a spoon balancing a potato on one end and coins on the other end, all on top of a calculator

An illustration of the option between one beefier server or multiple smaller servers. (although, in this image, the potato may be the same as the many coins, in reality multiple servers are typically better suited to handling more traffic).


Beefing up your server and adding more resources to it is known as scaling up (or vertical scaling). Adding more servers (or similar) is known as scaling outwards (or horizontal scaling).


Horizontal scaling is especially important for businesses requiring minimal downtime or high availability! Many suppliers boast about the availability of their systems and in their SLAs (service level agreements), often commit to 99.9% availability!


A multi-server environment can support more connections and services, helps to keep the system running, and can also cost significantly less each month than continually adding resources to a single server


Load balancing

A diagram showing server farms

So you want to run your website across multiple servers, how do you do it?


This is where a load balancer comes in. The classic analogy for a load balancer is the waiter at a restaurant.

A person making coffee in a coffee shop

In a small cafe, you might make the order straight to the cook. With a small website running on a single server, you’d make the request straight to the server.


However, with a larger restaurant, in order to deal with more orders, there may be multiple chefs. The chefs aren’t going to take the orders straight from the customers, so instead you have a waiter who can take orders from the customers and distribute them amongst the chefs.



This is the role of the load balancer, when you visit the website, it will direct your request to the server with the most capacity. As it says on the tin, it balances the load.

Chefs making fancy food

Load balancers often have other duties too. They also typically check on the health of the servers and can also dynamically spin up or down servers as required to handle the traffic.


Enabling your app to run across multiple servers

A typical website makes use of a database. Databases are used just about everywhere including banks, retail, websites and warehouses. Banks use databases to keep track of customer accounts, balances and deposits. Retail stores can use databases to store prices, customer information, sales information and quantity on hand.


Many websites also handle media. When you upload files to a website, they need to be stored somewhere. Think where do your pictures go when you upload them to Facebook?

A diagram showing the interaction between an app, database and media

With a website running on one server, this can be quite simple, as you can run the database on that server and store the uploaded files directly on the server.


But how would this work when you have a website running across multiple servers?


The answer is quite simple, you alter your application to expect a remote database and to store files remotely.


You would switch your application to use a remote database (e.g. AWS RDS) and you would also store those uploaded files etc somewhere else (somewhere off server where they can be accessed by the multiple servers -if using AWS, you would use AWS S3 - simple storage solution)

A diagram showing the interactions between apps, databases and media, for multiple servers

So you end up with a setup like this where your application is running on multiple servers which are all accessing the database and media from a remote location


There are a few other technical changes you need to make to the code in your app, including making it ‘stateless’ but this is just a quick overview of what you need to think about.


A quick summary

I hope this blog has given a helpful insight into what the cloud is and a rough overview of how many commercial websites are set up.


There’s a lot more to it and plenty more configuration which can be used. E.g. with Netflix and Spotify, there are loads more technologies used for streaming and queuing songs/videos. And with big sites handling lots of lots of data, using the right technology for the job is essential to make things run quickly and efficiently.


I’ve not gone into many of the technologies out there which are used on a daily basis by software engineers but this is intended to give you a basic but high level picture of what goes on behind the scenes when you go on your favourite websites.

262 views

Comments


bottom of page