“The cloud” changed the game so much, and so quickly, it’s difficult to remember what things were like before it arrived. But, not that long ago, getting server resources meant buying or leasing an actual box off the rack of a server farm. It wasn’t instant. It wasn’t cheap. And it usually required a great deal of technical knowledge.
“The cloud” freed us from the constraints of working with individual boxes. Instead, it offered an immense pool of resources that could be borrowed from as needed. Renting “shares” of the cloud eliminated the need to invest in hardware upfront and provided near instant scaling. Its value was a one-two combination of economies of scale and elastic autoscaling driving down the cost and “infrastructure as a service” lowering the knowledge barrier. We haven’t looked back since.
One of the most important cloud services is Amazon Elastic Cloud Compute (EC2) which was introduced in 2006. EC2 quickly became one of the most popular AWS services and remains so today.
What is EC2?
You can think of EC2 as the cloud equivalent of a server. A server, broken down to its essential elements, is a combination of storage and compute resources that can be remotely accessed.
What you’re actually getting with EC2 is a virtual machine which AWS calls an “instance.” It includes all the resources of a physical server but it’s not a distinct box — it’s a slice of a much larger pie. Functionally, it’s the exact same thing but behind the scenes it’s more like tapping into an ocean of resources. There aren’t really any downsides to using a virtual machine versus a physical machine. In fact, there are only advantages.
You can get as much, or as little, compute capacity as needed for your project and scale up and down as your needs change over time. And, it’s really easy to do so. EC2 is a web service so you can log in and create a new EC2 instance quickly and without the technical knowledge that would normally be required to provision a server.
Why use EC2?
In less than 10 minutes you can rent a slice of Amazon’s vast cloud network and put those computing resources to work on anything from data science to bitcoin mining.
EC2 offers a number of benefits and advantages over alternatives. Most notably:
Affordability
EC2 allows you to take advantage of Amazon’s enormous scale. You can pay a very low rate for the resources you use. The smallest EC2 instance can be rented for as little as $.0058 per hour which works out to about $4.18 per month. Of course, instances with more resources are more expensive but this gives you a sense of how affordable EC2 instances are.
With EC2 instances, you’re only paying for what you use in terms of compute hours and bandwidth so there’s little wasted expense.
Ease of use
Amazon’s goal with EC2 was to make accessing compute resources low friction and, by and large, they’ve succeeded. Launching an instance is simply a matter of logging into the AWS Console, selecting your operating system, instance type, and storage options. At most, it’s a 10 minute process and there aren’t any major technical barriers preventing anyone from spinning up an instance, though it may take some technical knowledge to leverage those resources after launch.
Scalability
You can easily add EC2 instances as needed, creating your own private cloud of computer resources that perfectly matches your needs. Here at Pagely a common configuration is an EC2 instance to run a WordPress app, an instance to run RDS (a database service), and an EBS so that data can easily be moved and shared between instances as they’re added.
AWS offers built-in, rules-based autoscaling so that you can automatically turn instances on or off based on demand. This helps you ensure that you’re never wasting resources but you also have enough resources available to do the job.
Integration
Perhaps the biggest advantage of EC2, and something no competing solution can claim, is its native integration with the vast ecosystem of AWS services. Currently there are over 170 services. No other cloud network can claim the breadth, depth, and flexibility AWS can.
What can you do with EC2 instances?
Anything you can do with a computer, you can do with EC2. Data scientists use EC2 instances to crunch large data sets. Animators use EC2 instances to render 3D worlds. At Pagely we use EC2 instances to serve websites for our Managed WordPress Hosting customers.
Instances come in a variety of different hardware configurations (memory and CPU) called “types” and are grouped into six families. Each family has a variety of instance types that have resources optimized for specific use cases.
To understand all the different ways EC2 instances can be leveraged, it can be helpful to explore the available instance families so you understand what’s available and how it can be put to use.
The first letter of the instance type indicates which family it is in. For instance, a c5.2xlarge is in the compute-optimized family (as indicated by the “C”) and a p3dn.24xlarge is in the accelerated computer family (as indicated by the “P”).
General purpose instances
A, T, and M
General purpose instances are simple instances with modest options best suited for testing environments. Generally, you would not want to use them as a production server.
M instances offer more balanced resources and are suitable for more general use (they’re powerful enough to be used for production on a budget).
Compute-optimized instances
C
Compute-optimized instances offer a low price per compute ratio making them a cost-effective solution for compute-heavy applications like web servers, machine/deep learning inference, ad serving, highly scalable multiplayer gaming, and video encoding.
Accelerated computing
P, G, F
These are GPU optimized instances for graphics-intensive applications or GPU compute applications. These instances are well-suite for speech analysis, machine learning, 3D rendering, and genomics research.
Memory optimized instances
X1e, X1, R
Memory-optimized instances are for applications that don’t require a lot of compute resources and instead require a lot of RAM. Often these instances are useful for data science applications — such as data mining and data analysis — where the data set can be stored in RAM.
Storage optimized instances
H, I, D
Storage optimized instances deliver high disk throughput, low latency SSD, or HDD storage for a variety of storage heavy applications like distributed file systems, big data workload clusters, data processing applications like Apache Kafka, elastic search, and NoSQL databases.
The range of hardware options on these instance types can be overwhelming. You can use a resource like https://www.ec2instances.info/ to make comparisons and find the hardware that’s best for your application.
Persistent storage with EBS
An instance can be launched with its native storage (boot disk) or, optionally, Elastic Block Store (EBS) can be added as a service. EBS’s main advantage is that it can be easily attached to any instance. Using the storage provided by an instance makes it more difficult to share data with an instance and once that instance is turned off that data is no longer available (this is called ephemeral storage).
Pricing
Amazon provides a generous free tier for exploring many of its products including 750 free hours over 12 months for EC2 instances.
When you’re ready to purchase an instance they offer three options:
- On-Demand Instances
- Pay only for what you use.
- No long-term commitments or upfront payments.
- Reserved Instances
- One-time, upfront payment for a period of 1-3 years.
- Machine is always on.
- Save a significant amount of money by pre-paying.
- Spot Instances
- Purchase unused EC2 instances at a discount for significant cost savings.
- Machine could be taken down by Amazon so not a good option if continuous uptime is important.
So to simplify things, a reserved instance is great if you have a long-term need for an instance that is always on.
If you want to save money, you can go with an On-Demand or Spot instance but if it’s important that machine be available when you need it, On-Demand is your best option.
This flowchart from Cloud Academy summarizes this nicely:
Why we use EC2 at Pagely
Here at Pagely we use C5 instances and VBurst instances. We analyzed many instance types and found these best suited for the unique resource demands of WordPress. Along with AWS RDS as our database solution, they allow us to serve web pages quickly and reliably.
The reason we chose EC2 over competing solutions can be boiled down to one important advantage: EC2 is part of the AWS cloud ecosystem. No other cloud solution comes close in terms of number of services (over 170+ and counting). The breadth and depth of services offered by AWS is currently unmatched. There are less expensive cloud providers on the market but we chose the AWS ecosystem because it offers our customers unparalleled flexibility. All those services and instance types allow us to meet the demands of any customer — whether they’re a blogger, an ecommerce store, or an international enterprise with unique and demanding requirements. AWS can do it all — reliably and securely.