There’s lots of different instance types available from AWS, all of which excel for certain workloads. There are also different ways of paying for your instances which can save you a lot of money. With all the different combinations available, it’s essential that you pick the right instance types to avoid paying more than you need to.
Instance pricing
There’s 3 different ways of paying for your instances:
Pricing type | How it works | Ideal for |
On-demand instances | Pay for only what you use. | Temporary and short running workloads that can’t be interrupted (i.e. video rendering) |
Reserved instances | Reserve capacity, pay a lower rate. Save up to 70% compared with on-demand. | Long running workloads that need to be available all the time for a period over 12 months (i.e. web servers). |
Spot instances | An auction of unused compute capacity on AWS. The max you pay is the current on-demand price. Can potentially be interrupted. | Temporary and short running workloads that can be interrupted (i.e. non-critical data processing). |
Instance types
There are a lot of general and speciality instance types available from AWS; picking the right one for your workload is crucial for optimising performance and cost.
Common applications and recommended instance types
Web and application servers
Regular web servers need to be running all the time, so you should reserve your instance to save on running costs. You probably want to choose a general purpose instance type such as T2/T3. This is ideal for running a regular web application such as NodeJS, Python, PHP, Go etc. A reserved T2/T3 would be a good choice for this kind of server.
Database/caching servers
Database servers need to be running all the time, so reserving your instance makes sense. Depending on the type of database your are running you can choose between memory or storage optimised instances. If you’re running a NoSQL database that persists to disk such as MongoDB, you’ll need an I series instance such as an I3. If you’re running an in-memory database such as Redis you’ll need an R series instance such as R4/R5.
Video encoding servers
Servers performing video encoding tasks only need to be running when there is work to do. When encoding tasks are running they can last hours and usually can’t be resumed if interrupted. On-demand instances are best for this kind of workload. As video encoding is CPU intensive, a CPU optimised instance type such as C4/C5 would be a good choice.
I’ve included a more detailed list below if you have a less common scenario:
Common Instance types
Speciality | Instance type | Ideal for |
General purpose | T (i.e. T2, T3, T3a) | General workloads that don’t fit into any other speciality types, such as general web application servers. |
General purpose (extra memory) | M (i.e. M4, M5, M5a, M5n, M6g | General workloads that require additional memory, such as data processing. |
Compute optimized | C (i.e. C4, C5, C5n) | CPU intensive tasks as video encoding, high-performance servers and analytics. |
Memory optimized | R (i.e. R4, R5, R5a, R5n) | Memory intensive tasks such a in-memory caches and databases. |
Storage optimized | I (i.e. I3, I3en) | Storage intensive tasks such as databases (i.e. Cassandra, MongoDB). |
Speciality instance types
Speciality | Instance type | Ideal for |
General purpose Arm | A1 | General workloads that don’t fit into any other speciality types and benefit from Arm. |
Accelerated computing (GPU) | P (i.e. P2, P3) | Extremely high performance computing such as deep learning. |
I’ve left off some instance types as they are only useful in very unique situations, the full list can be found here: https://aws.amazon.com/ec2/instance-types/