Benchmarking Amazon EC2 instances. The newer type, the better?
AWS continuously updates its cloud services and releases new instance types and this leads to the following questions from customers:
In this article I compared different generations for general purpose EC2 instances of “M” type. The “Large” size was used (2 vCPU, 8 Gb RAM), including the following:
For M5a, M5zn, M5n, M5, M6a, M6in, M6i, M6g, M7a, M7i, M7i-flex, M7g, M8g instance types.
Instances specification and pricing
AWS documentation and `lscpu` tool were used to collect the following information:
In general, we have three CPU vendors in this table:
Prices information were taken for “on-demand” instances in US-East-1 (N. Virginia region) in May 2025.
`M6g` is the cheapest one
Network performance
For this test, I used the speedtest tool, for example (M8g test):
$ curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 -
Retrieving speedtest.net configuration...
Testing from Unknown (13.217.55.225)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Shentel (Ashburn, VA) [1774.52 km]: 1.684 ms
Testing download speed................................................................................
Download: 5921.29 Mbit/s
Testing upload speed......................................................................................................
Upload: 3541.71 Mbit/s
Several attempts were performed for every instance to avoid exidental performance degradation. And here is the result:
`M8g` and `M7a` showed the best results
CPU performance
sysbench was used to test CPU and Memory, for example:
$ sysbench cpu run
sysbench 1.1.0-3ceba0b (using bundled LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Prime numbers limit: 10000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 3342.29
Throughput:
events/s (eps): 3342.2875
time elapsed: 10.0003s
total number of events: 33424
Latency (ms):
min: 0.30
avg: 0.30
max: 0.34
95th percentile: 0.30
sum: 9996.44
Threads fairness:
events (avg/stddev): 33424.0000/0.00
execution time (avg/stddev): 9.9964/0.00
or with 4 threads:
$ sysbench --threads=4 cpu run
sysbench 1.1.0-3ceba0b (using bundled LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 4
Initializing random number generator from current time
Prime numbers limit: 10000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 6790.93
Throughput:
events/s (eps): 6790.9294
time elapsed: 10.0003s
total number of events: 67911
Latency (ms):
min: 0.29
avg: 0.59
max: 20.31
95th percentile: 0.30
sum: 39964.88
Threads fairness:
events (avg/stddev): 16977.7500/8.29
execution time (avg/stddev): 9.9912/0.01
CPU speed: events per second
`sysbench` measures raw CPU performance by calculating prime numbers up to a certain value. Shows per-thread CPU capability and latency.
`M7a` is the top 1
CPU Latency (Average) (ms)
`M7a` is the top
Memory performance
sysbench can test memory bandwidth (read/write) and latency. Helps identify RAM speed and NUMA performance.
$ sysbench memory run
sysbench 1.1.0-3ceba0b (using bundled LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Running memory speed test with the following options:
block size: 1KiB
total size: 102400MiB
operation: write
scope: global
Initializing worker threads...
Threads started!
Total operations: 57387660 (5738739.43 per second)
56042.64 MiB transferred (5604.24 MiB/sec)
Throughput:
events/s (eps): 5738739.4302
time elapsed: 10.0000s
total number of events: 57387660
Latency (ms):
min: 0.00
avg: 0.00
max: 0.06
95th percentile: 0.00
sum: 3962.93
Threads fairness:
events (avg/stddev): 57387660.0000/0.00
execution time (avg/stddev): 3.9629/0.00
`M5zn` is the top
MUTEX
sysbench measures pthread mutex lock/unlock performance under contention. Simulates thread synchronization overhead.
$ sysbench mutex run
sysbench 1.1.0-3ceba0b (using bundled LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Initializing worker threads...
Threads started!
Throughput:
events/s (eps): 5.5396
time elapsed: 0.1805s
total number of events: 1
Latency (ms):
min: 180.46
avg: 180.46
max: 180.46
95th percentile: 179.94
sum: 180.46
Threads fairness:
events (avg/stddev): 1.0000/0.00
execution time (avg/stddev): 0.1805/0.00
`M7a` is the top
General purpose vs. Compute optimized vs. Memory optimized
In the previous tests I compared CPU and Memory performance for different generations of the “General Purpose” instances (M type), but logically, if you care about CPU performance the most, you would use the “Compute optimized” instance and the same logic with Memory performance and “Memory optimized” instances.
Let’s compare CPU and Memory performance for the latest generations of:
First of all, what is the price (on-demand instance in us-east-1 region):
CPU, Memory and Network performance are nearly the same:
So, the only chance to see difference in performance is to use the “optimized” instances for relevant workloads:
Conclusion
The newer instance type, the better? Not at all. In this post, I benchmarked different EC2 families and generations, tested CPU, Memory and Network performance and provided comparison graphs.
AWS Ambassador | AWS Community Builder | AWS User Group Leader | Platform Engineering Ambassador | 15x AWS certified, 4x Kubernetes (CKA, CKAD, CKS, KCNA) | Lead DevOps
2mohttps://medium.com/@oleksii.bebych/benchmarking-amazon-ec2-instances-the-newer-type-the-better-82437b984922