Benchmarking Amazon EC2 instances. The newer type, the better?

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:

  • Which instance type is better for my needs?
  • Which instance type is cheaper?
  • How differs CPU/Networking performance between instance types?

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:

  • Pricing
  • CPU performance
  • RAM performance
  • Network performance

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:

Article content

In general, we have three CPU vendors in this table:

  • Intel (M5, M5zn, M5n, M6i, M6in, M7i, M7i-flex)
  • AMD (M5a, M6a, M7a)
  • AWS Graviton — ARM architecture (M6g, M7g, M8g)

Prices information were taken for “on-demand” instances in US-East-1 (N. Virginia region) in May 2025.

Article content
Article content

`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:

Article content
Article content

`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.

Article content
Article content
Article content

`M7a` is the top 1

CPU Latency (Average) (ms)

Article content
Article content
Article content

`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        
Article content
Article content
Article content

`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        
Article content
Article content
Article content

`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:

  • General purposem 8g.large (2 vCPU, 8 Gb RAM)
  • Compute optimized c8g.large (2 vCPU, 4 Gb RAM)
  • Memory optimized r8g.large (2 vCPU, 16 Gb RAM)

First of all, what is the price (on-demand instance in us-east-1 region):

Article content

CPU, Memory and Network performance are nearly the same:

Article content

So, the only chance to see difference in performance is to use the “optimized” instances for relevant workloads:

  • `Compute optimized` Run 100% CPU-bound real-world apps (e.g., video encoding, compute-heavy tasks) that scale with vCPU count
  • `Memory optimized` Load >50–75% of system memory or run large in-memory DBs (Redis, Memcached, Elasticsearch)
  • `General purpose` Need balanced performance (web apps, microservices, small DBs)

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.

Oleksii Bebych

AWS Ambassador | AWS Community Builder | AWS User Group Leader | Platform Engineering Ambassador | 15x AWS certified, 4x Kubernetes (CKA, CKAD, CKS, KCNA) | Lead DevOps

2mo

To view or add a comment, sign in

Others also viewed

Explore topics