How to choose the right EC2 types for application service work loads
There are too many variations of EC2 instances available and the list keeps on growing. It’s rather confusing to choose which ones are the best for your use case. For typical service work loads just consider only the below types of instances.
- General purpose (m5 series, t3 series — burstable)
- Memory Optimized (r5 series)
- CPU Optimized (c5 series)
Categorize your work loads into (a) production (b) non production
- For workloads with occasional spikes use burstable cpu types ( t3 series)
- Use lower performance type (ARM based) instances in non production work loads.
- Always use the latest generation in every category of the EC2s. For example, in general purpose category use m5 series, in memory optimized category use r5 series. These will be better performant and low cost compared to the the previous generation in the same instance family.
Sample comparision of prices and the resources of the EC2 instances mentioned in the diagram below. This representation might help decide the most cost affective instance for a kind of work load having known Memory and CPU requirement.

How to decide which instance type is optimal for a new service?
- Define the average and max response time for the new service’s APIs
- Define the expected throughput.
- Deploy the service on to each one of the instance types.
- Perform load testing.
- Choose the most cost effective instance type which fulfils the response time and throughtput requirements.
- For Node.js kind of applications run the service using pm2 in cluster mode so that the resources are utilized efficiently.
Cost optimization measures
Identify the work loads which are not continous in nature.
- Only needed in day time, consider stopping those instances during the night time using a simple scheduled jenkins job using AWS API.
- On deman like bringing in a cluster only during some kind of perofrmance testing activity or whenever the test engineers are working. Keep them in stopped state when not in use may be using a simple jenkins job using AWS API.
Once the right instance families are chosen and the services are running fine for certain duration lets say for about 2 weeks or a month, purchase a savings plan.
- Savings plan is a commitment of hourly usage of compute resources for a minimum duration of a year. This will reduce about 20% from your ‘compute’ bill.
- Commit for 65% of your current utilization. The Savings plan commitment should be post applying the savings because of the Savings Plan. For example your compute before applying savings is $5 per hour then take $3 per hour savings plan. Exclude on demand or scheduled workloads from the savings plan.
- Choose “Compute Savings Plan” over “EC2 instances Savings Plan to have better flexibility.
In case if you want to check how well the EC2s are provisioned against the workloads, refer the recommendations given by “AWS Compute optimizer service”. This service is free to use. If needed you can update the instance types based on the recommendation suggested by this service.
Caveat: Make sure your applications/services run on all the instance types you choose before going live with the recommendations. These recommendations are not applicable for running databases/caching systems or kafka clusters.