Recently I decided to teach myself AWS, but I soon started to wonder why and when to use AWS EC2 rather than renting a server from a conventional server provider. Why? the main reasons are…
- EC2 seems so convoluted with many acronyms and terms (e.g. AMI, ESB, EFS), all of which makes it difficult to comprehend what EC2 is and when it’s useful
- EC2 offers so many pricing plans that I don’t know how to pick one
In this article, I’d like to record what I’ve learned about the following things.
- What is AWS EC2?
- Why should I choose cloud hosting?
- When does choosing EC2 make sense?
(If you just want to know the conclusion, scroll down to the bottom!)
So, what is EC2?
Here is the definition from the official site.
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.
To put it in the simplest way, what you can do with EC2 is to host your app in a cloud computing environment.
EC2 has 4 types of pricing. (Following explanations are extracted from AWS’ website)
With On-Demand instances, you pay for compute capacity by per hour or per second depending on which instances you run. No longer-term commitments or upfront payments are needed.
On-Demand instances are recommended for:
- Users that prefer the low cost and flexibility of Amazon EC2 without any up-front payment or long-term commitment
- Applications with short-term, spiky, or unpredictable workloads that cannot be interrupted
- Applications being developed or tested on Amazon EC2 for the first time
Amazon EC2 Spot instances allow you to request spare Amazon EC2 computing capacity for up to 90% off the On-Demand price.
Spot instances are recommended for:
- Applications that have flexible start and end times
- Applications that are only feasible at very low compute prices
- Users with urgent computing needs for large amounts of additional capacity
Reserved Instances provide you with a significant discount (up to 75%) compared to On-Demand instance pricing. In addition, when Reserved Instances are assigned to a specific Availability Zone, they provide a capacity reservation, giving you additional confidence in your ability to launch instances when you need them.
For applications that have steady state or predictable usage, Reserved Instances can provide significant savings compared to using On-Demand instances.
Reserved Instances are recommended for:
- Applications with steady state usage
- Applications that may require reserved capacity
- Customers that can commit to using EC2 over a 1 or 3 year term to reduce their total computing costs
A Dedicated Host is a physical EC2 server dedicated for your use. Dedicated Hosts can help you reduce costs by allowing you to use your existing server-bound software licenses, including Windows Server, SQL Server, and SUSE Linux Enterprise Server (subject to your license terms), and can also help you meet compliance requirements.
- Can be purchased On-Demand (hourly).
- Can be purchased as a Reservation for up to 70% off the On-Demand price.
Whichever plan you choose, the price will be determined by how much your app/website (i.e. instance) has used.
However, before deciding whether EC2 is suitable for my app or not, I need to know when I should use cloud hosting (instead of shared/dedicated hosting)
Why should I use cloud hosting?
Because it’s fast, scalabile and secure
Shared servers contain multiple websites. So, when one site is experiencing huge traffic, other sites on the same server can be slow. Also, when one website in a shared server is hacked, other sites can be targeted by the hacker.
In cloud hosting, your website/app will be on multiples servers, and the server provider “can bounce your website hosting between servers as it adjusts to performance spikes and other stresses. ” So, cloud hosting is (in theory) more dynamic, and therefore it tends to be faster, more scalable and secure.
When does it make sense to choose cloud hosting?
It makes sense when the website is expected to serve a lot of clients, security is an especially important issue, and/or the amount of traffic changes drastically.
For example, E-commerce websites are likely to receive benefits from cloud hosting. The reasons are…
- Study has shown that the performance of that type of websites is often highly correlated with the number of visitors.
- It enhances security, given that E-commerce websites often own a large number of customers’ information
On the other hand, bloggers and developers looking for a spot to house some hobby projects may well choose shared servers, provided that the performance and scalability are not higly critical.
How expensive is cloud hosting?
Cloud hosting is more expensive than shared hosting. In the case of a2 hosting, for example…
Why do we use EC2 (instead of a shared server from a common server provider)?
Now, we have learned the very basics of what cloud hosting is and how it differs from a shared server, I’d like to see when it makes sense to choose EC2 over the conventional server providers.
Merits of EC2
Let’s go over what EC2 has which normal server providers don’t.
1. You’ll pay for how much you’ve used
As mentioned above, no matter which plan you choose, the price will be determined by the usage of instance. This is an advantage when your app isn’t having huge traffic.
2. You can use it immediately
Unlike applying for a server rental plan of a normal server provider, EC2 allows you to use it immediately. Applying for an EC2 instance takes a few minutes.
3. You can choose a variety of OS configurations
EC2 allows you to choose…
- Instance storage
- Networking Performance
- OS (including various distros of Linux, Windows server, etc)
What’s more, you are allowed to change the OS specifications of an instance after you’ve created an instance.
4. You can replicate a server and use it separately from the original one
In EC2, the details of a server are stored in a format called AMI. Therefore…
- You can copy an AMI and create a test server from it
- You can copy your development server to the live server
5. You can choose the region
EC2 allows you to use regions across the world. By choosing the region close to where you offer services, you can improve the performance of the website/app.
6. It’s already well integrated with other AWS services
Here is an except from AWS’ website.
Amazon EC2 is integrated with most AWS services such as Amazon Simple Storage Service (Amazon S3), Amazon Relational Database Service (Amazon RDS), and Amazon Virtual Private Cloud (Amazon VPC).
Using EC2 makes sense when…
All things considered, using EC2 makes sense when…
- You wish to pay based on how much your website/app has used, rather than paying a fixed amount of fee
- You have to launch your app soon
- You wish to use an OS with a specific configuration which you can’t find in a conventional server provider (and may have to change it in the future)
- You wish to be able to replicate the instance for some reasons (e.g. testing, redundancy, etc)
- You wish to be able to choose the region for each website/app
… but these are just my thoughts. Let me hear yours too!