EC2 Pricing Explained
Published: 2021-04-21 13:42:43

## How Does EC2 Pricing Work?
Instead of continuously buying, maintaining, and upgrading expensive hardware, You can use Amazon’s Elastic Compute Cloud (EC2) for scalable computing capacity in Amazon’s cloud (AWS). Launch precisely the number of servers you need, manage your own storage, and configure your own security and networking environment.

[Amazon prices EC2 resources](https://spot.io/resources/aws-ec2-pricing-the-ultimate-guide/) using a basic unit of computing resources called an instance—a virtual machine you can rent on a per-hour basis. Amazon offers different instance type families to suit your needs—those for general-purpose computing and those optimized for storage, processing, memory, and more. 

In each instance family, you can select an instance size, which determines the processing power, memory and storage capacity, and even networking bandwidth available to the instance.
## EC2 Instance Families
Amazon offers five instance families to suit your workload requirements. You can mix instances from different families, switch an instance to another family, and even reconfigure instances within the families. Select from:

* **The General Purpose family**—for the optimal balance of compute-memory-network resources. Ideal for web servers, code repositories, and other equally proportioned resource workloads.
* **The Compute Optimized family**—best suited for compute-intensive applications, such as machine learning inference, dedicated gaming servers, scientific modeling, batch-processing workloads, and other workloads requiring high-performance processing.
* **The Memory Optimized family**—rapid performance for large data in-memory processing.
* **The Storage Optimized family**—for applications requiring low-latency operations or throughput in terms of thousands of I/O operations/second (IOPS). Provides fast read/write access to locally stored data sets.
* **The Accelerated Computing family**—for efficient graphic processing, data pattern matching, or floating-point number calculation, you should consider these instances which offer [graphical processing units (GPUs) for machine learning, deep learning](https://www.run.ai/guides/gpu-deep-learning/) and other parallel compute workloads, and field-programmable gate arrays (FPGAs) in addition to standard CPUs. 

## Amazon EC2 Pricing Models
Amazon provides several pricing models, which you can leverage depending on your scale and the nature of your workloads.
### Free Tier
So long as you only use EC2 micro instances, you can remain in Amazon’s free tier pricing model. You can use a Linux or Windows t2.micro instances (t3.micro where t2.micro is unavailable) for 750 hours per month, for an entire year.
### On-Demand
For customers who require short-term workloads that cannot be disrupted, or those developed or workloads new to the Amazon cloud, on-demand instances are ideal. Pay by the hour or second—depending on the instances you run—for compute capacity. Gauge your required capacity, and pay for actual usage with no upfront payments, and no long-term commitments.
### Spot Instances
For users whose urgent computing needs require large additional compute capacity, or for applications with flexible start/end times or that are feasible only at low compute prices, Amazon offers spot instance pricing. Using EC2 spot instances, you can access spare EC2 compute capacity at less than 90% of Amazon’s on-demand prices.
### Reserved Instances
If you commit to one or three years of EC2 usage, or if your applications require reserved capacity or steady-state usage, reserved instances offer a significant discount of up to 75% off on-demand pricing. Your capacity is reserved within a specific availability zone.
### Savings Plans
Amazon’s flexible savings plan offers savings of up to 72% on EC2 and Fargate usage. In return, you will have to commit to one or three years of a certain level of usage (in dollars per hour) of individual instance families in a single region. You can still change instances within a family within a region, and you may choose to launch instances in any availability zone, operating system, tenancy, or size.
### Per Second Billing
Per-second billing is another pay-as-you-go option. This can be critical if your instances run for irregular time periods, as is often the case with gaming applications, dev/testing, batch processing, data processing, and analytics. Amazon bills EC2 usage and provisioned [AWS EBS volume storage](https://bluexp.netapp.com/blog/ebs-volumes-5-lesser-known-functions) at one-second increments with a 60-second minimum and deducts unused minutes and seconds in an hour from the total. 
## AWS EC2 Cost Optimization
### Identify Amazon EC2 Instances with Low-Utilization
To reduce your costs, you can downsize or optimize idle or low-utilization EC2 instances. The AWS Cost Explorer tool provides a Resource Optimization report, which provides instance-type recommendations. Compute Optimizer is another tool that issues recommendations for up-or downsizing within and across instance families, thus helping you remove performance bottlenecks, as well as for autoscaling group EC2 instances.
### Use Amazon EC2 Spot Instances to Reduce EC2 Costs
Spot instances can reduce your costs by up to 90% for fault-tolerant workloads. Launch spot instances and on-demand ones with EC2 autoscaling to meet a target capacity. Even if a spot instance is interrupted, autoscaling will automatically maintain the target capacity while dealing with spot instance requests. Spot instances are especially fitting for containerized workloads, high-performance computing (HPC), CI/CD, big data and other development and test workloads.
### Scheduled RIs
Whether you are running cloud-based workloads on a part-time or periodic (monthly, weekly, or daily) basis, you may be able to leverage scheduled reserved instances (RIs) to significantly cut down on your EC2 bill. If your application runs on a perfectly defined timeline, scheduled RIs allow you to reserve capacity on a recurring schedule. Choose your time, reserve your instance type, purchase an RI coupon, and it will launch on schedule.
## Conclusion
In this article, I reviewed the basics of EC2 pricing:

* EC2 instance families, including General Purpose, Compute Optimized and Memory Optimized
* EC2 pricing models, including on-demand, reserved instances and spot instances
* Tips to optimize your EC2 costs, including shutting down or right-sizing instances with low utilization, using spot instances, and leveraging reserved instances for long-running workloads

I hope this will be useful and you deepen your use of Amazon EC2 and optimize your workloads to reduce costs.