AWS EC2 Instance Comparison: C6g vs M6g vs R6g
AWS has a lot of different instance types and it can be difficult to decide which instance type would be the best for a particular use-case. In this article, we will compare three popular instance types: C6g, M6g and R6g, across various dimensions such as their specs, their performance as well the cost.
Comparing C6g, M6g and R6g instance families
M6g Instances
Amazon EC2 M6g Instances offer a balance of compute, memory and networking resources and thus they are ideal for a broad range of workloads.
R6g Instances
Amazon EC2 R6g instances are memory-optimized instances. R6g instances are well suited for memory-intensive applications such as high-performance databases, distributed web scale in-memory caches, mid-size in-memory databases, real-time big data analytics, and other enterprise applications.
C6g Instances
Amazon EC2 C6g instances are optimized for compute. C6g instances offer the lowest price per vCPU in the Amazon EC2 family and are ideal for running advanced compute-intensive workloads.
Performance
We compared the performance between these instance families by running a bunch of tests on the following instances:
- c6g.2xlarge
- m6g.2xlarge
- r6g.2xlarge
Instance Type | Number of cores | Memory (GB) |
---|---|---|
c6g.2xlarge | 8 | 16 |
m6g.2xlarge | 8 | 32 |
r6g.2xlarge | 8 | 64 |
We will be using Sysbench to run various tests to measure the CPU, Memory and Disk performance.
CPU
We ran the CPU benchmark using the following command: sysbench cpu --cpu-max-prime=20000 --threads=8 run
.
We will be comparing the total time
as well as the total number of events
for the benchmark from start to end.
As we can see from the results below, c6g.2xlarge
performed the best on this benchmark.
c6g.2xlarge
General statistics:
total time: 10.0009s
total number of events: 86278
m6g.2xlarge
General statistics:
total time: 10.0009s
total number of events: 86191
r6g.xlarge
General statistics:
total time: 10.0009s
total number of events: 86191
Memory
We ran the CPU benchmark using the following command: sysbench memory --memory-block-size=1M --memory-total-size=100G --num-threads=8 run
.
We will be comparing the Operations performed
for the different instance types.
In this benchmark, r6g.2xlarge
performed the best.
c6g.2xlarge
Total operations: 102400 (101111.56 per second)
102400.00 MiB transferred (101111.56 MiB/sec)
m6g.2xlarge
Total operations: 102400 (101209.29 per second)
102400.00 MiB transferred (101209.29 MiB/sec)
r6g.2xlarge
Total operations: 102400 (101260.04 per second)
102400.00 MiB transferred (101260.04 MiB/sec)
Disk performance
We also ran simple read & write benchmarks to test the performance of the EBS volumes on each of these instance types.
m6g.2xlarge
instance performed the best on the disk performance benchmarks.
c6g.2xlarge
Write
dd bs=16k count=102400 oflag=direct if=/dev/zero of=test_data
102400+0 records in
102400+0 records out
1677721600 bytes (1.7 GB, 1.6 GiB) copied, 72.8331 s, 23.0 MB/s
Read
dd bs=16K count=102400 iflag=direct if=test_data of=/dev/null
102400+0 records in
102400+0 records out
1677721600 bytes (1.7 GB, 1.6 GiB) copied, 41.5291 s, 40.4 MB/s
m6g.2xlarge
Write
dd bs=16k count=102400 oflag=direct if=/dev/zero of=test_data
102400+0 records in
102400+0 records out
1677721600 bytes (1.7 GB, 1.6 GiB) copied, 72.2482 s, 23.2 MB/s
Read
dd bs=16K count=102400 iflag=direct if=test_data of=/dev/null
102400+0 records in
102400+0 records out
1677721600 bytes (1.7 GB, 1.6 GiB) copied, 35.2356 s, 47.6 MB/s
r6g.2xlarge
Write
dd bs=16k count=102400 oflag=direct if=/dev/zero of=test_data
102400+0 records in
102400+0 records out
1677721600 bytes (1.7 GB, 1.6 GiB) copied, 68.3376 s, 24.6 MB/s
Read
dd bs=16K count=102400 iflag=direct if=test_data of=/dev/null
102400+0 records in
102400+0 records out
1677721600 bytes (1.7 GB, 1.6 GiB) copied, 45.2198 s, 37.1 MB/s
Pricing
We compared the prices between these instance families by looking at the price per hour for each instance type.
C6g instances are the cheapest amongst the three instance families whereas the R6g instances are the most expensive. R6g instances are almost 50% more expensive than C6g instances.
Price/core for Linux on-demand instances:
Instance Type | Price / hour |
---|---|
c6g.2xlarge | $0.2720 |
m6g.2xlarge | $0.3080 |
r6g.2xlarge | $0.4032 |
Conclusion
The new C6g instances offer the best processor performance as well as price and should be the go-to instance type for most use-cases.
If the use-case requires a lot of memory, then the choice becomes either between M6g and R6g. Critical applications such as in-memory databases and caches should use the R6g instances since they are optimized for such use-cases.
Applications such as batch processing systems are probably better suited for M6g instances since they need the additional memory but are not as performance-critical.