EC2
Amazon Elastic Compute Cloud (EC2) is a web service that provides secure and resizable compute resources in the AWS Cloud. The EC2 service allows you to provision and configure capacity with minimal effort. It provides you with easy control of your compute resources.
EC2 reduces the time required to obtain and boot new servers (EC2 instances) from hours to just minutes. This efficiency allows you to scale capacity vertically (up and down, making your server resources bigger or smaller) and horizontally (out and in, adding more capacity in the form of more instances) as your computing requirements change. As you might recall from previous chapters, this property is known as elasticity.
The many benefits of EC2 in AWS include the following:
EC2 allows you to control expenses as your business expands; you pay only for the resources you use as your business grows.
EC2 provides you with the tools to build failure-resilient applications that are isolated from common failure scenarios.
EC2 enables you to increase or decrease capacity in minutes rather than in hours or days. You can commission one, hundreds, or even thousands of server instances simultaneously.
You have complete control of your EC2 instances. You have root access to each one, and you can interact with them as you would any traditional virtual machine.
You can stop your EC2 instance while retaining the data on your boot partition and then subsequently restart the same instance using web service APIs. Instances can be stopped and started remotely using web service APIs.
You can choose among multiple instance types, operating systems, and software packages. Instance types inside AWS permit the choice of emphasis on CPU, RAM, and/or networking resources. (You’ll see more details later in this section.)
EC2 integrates with most AWS services, such as Simple Storage Service (S3), Relational Database Service (RDS), and Virtual Private Cloud (VPC). This tight integration allows you to use EC2 for a wide variety of compute scenarios.
EC2 offers a reliable environment where replacement instances can be rapidly and predictably commissioned. The service runs within Amazon’s proven network infrastructure and data centers. AWS offers as much as 99.95% availability for each region.
Amazon EC2 works in conjunction with Amazon VPC to provide security and robust networking functionality for your compute resources:
- Your compute instances are located in a VPC with an IP address range that you specify.
- You decide which instances are exposed to the Internet and which remain private.
- Security groups and network access control lists (NACLs) allow you to control inbound and outbound access to and from your network interfaces.
- You can connect your existing IT infrastructure to resources in your VPC by using industry-standard encrypted IPsec virtual private network (VPN) connections, or you can take advantage of a private AWS Direct Connect option.
You can provision your Amazon EC2 resources as dedicated instances. Dedicated instances are Amazon EC2 instances that run on hardware dedicated to a single customer for additional isolation. Alternatively, you can provision your Amazon EC2 resources on dedicated hosts, which are physical servers with EC2 instance capacity entirely dedicated to your use. Dedicated hosts can help you address compliance requirements and reduce costs by allowing you to use your existing server-bound software licenses.
As previously mentioned, a nice feature of AWS EC2 is the wide variety of instance types you can select from to have the right hardware platform in place for your virtual machines. Instance types fall into the following categories:
General purpose
Compute optimized
Memory optimized
Storage optimized
HPC optimized
There are several pricing models for EC2, as shown in Figure 13-1.
Figure 13-1 EC2 Pricing Options
These pricing options are as follows:
On-Demand Instances: With this model, you pay for compute capacity by the hour (or even by the second with some AMIs), with no long-term commitments. You can increase or decrease your compute capacity, depending on the demands of your application, and pay the specified hourly rate only for the instances you use. The use of On-Demand Instances frees you from the costs and complexities of planning, purchasing, and maintaining hardware. As mentioned earlier in this chapter, this model also transforms what are commonly substantial fixed costs into much smaller variable costs.
This type of pricing model is appropriate when you are testing a solution for the first time, or when you are using short-term or unpredictable workloads that cannot be interrupted.
Savings Plans: This model provides you with a significant discount (up to 72%) compared to On-Demand Instances pricing. In order to save that much, you must commit to a certain amount of compute resources for a one- to three-year term.
There are three options under Savings Plans: Compute Savings Plans (which apply to usage across EC2, Lambda, and Fargate), EC2 Instance Savings Plans, and Amazon SageMaker Savings Plans.
This type of pricing plan is appropriate for committed and steady-state workloads.
Spot Instances: This pricing model allows you to bid on spare EC2 computing capacity. Because Spot Instances pricing is discounted compared to On-Demand Instances pricing, you can significantly reduce the cost (up to 90%) of running your applications.
This type of pricing plan is recommended for fault-tolerant or stateless workloads. It is also appropriate for applications that can run on heterogeneous hardware and applications that have flexible start and end times.