Sub topic 6
What AWS Graviton is and when it fits
This chapter assumes you know basic EC2 concepts (instances, instance types, AMIs), can use the AWS CLI, and have used Docker on Linux. You should also have right-sized your instances first, as the earlier chapters describe.
What Graviton is
AWS Graviton is a family of server processors that AWS designs itself. They use the Arm64 instruction set (also called aarch64) instead of x86-64, which Intel and AMD processors use. Graviton instance types carry a g in the family name. Examples are m7g, c7g, r7g and t4g. A name such as m7i (Intel) or m7a (AMD) is x86-64.
Two design points matter for your workloads:
- Each vCPU on a Graviton instance is a full physical core. On most x86 instances, a vCPU is a hyperthread, and two vCPUs share one core. A Graviton instance with 4 vCPUs therefore often behaves differently from an x86 instance with 4 vCPUs under multithreaded load.
- Graviton instances are usually priced lower than the comparable x86 size. Check current prices for your Region, because the gap varies by family and generation.
Together, these two points are why Graviton often gives better price-performance. The result depends on your workload, so measure it. A later chapter covers benchmarking.
When Graviton fits
Graviton tends to fit when the software already runs on Linux and has Arm64 builds available. Typical good candidates:
- Web and API servers written in Java, Go, Python, Node.js, .NET, PHP or Ruby.
- Containerized microservices.
- Caches and open-source databases, such as Redis, Memcached, MySQL and PostgreSQL.
- Batch processing and data pipelines that are CPU-bound.
Graviton fits less well, or needs more work, in these cases:
- Software distributed only as x86-64 binaries, such as some commercial or legacy packages.
- Code with hand-written x86 assembly or x86-specific intrinsics (SIMD instructions).
- Workloads that need a feature only specific x86 families offer.
- Windows workloads, because Windows Server is not available on Graviton instances.
The next chapter covers how to check compatibility in detail. For now, treat Graviton as a good candidate when the answer to "does every component have an Arm64 build?" is yes.
Checking what is available
List the current-generation instance types that run on Arm64:
aws ec2 describe-instance-types \
--filters Name=processor-info.supported-architecture,Values=arm64 Name=current-generation,Values=true \
--query 'InstanceTypes[].InstanceType' \
--output textA Graviton instance must launch from an Arm64 AMI. An x86-64 AMI will not work, and EC2 rejects the launch because the architectures do not match. Look up the latest Amazon Linux 2023 Arm64 image through the public SSM parameter:
aws ssm get-parameter \
--name /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-arm64 \
--query 'Parameter.Value' \
--output textAfter you connect to an instance, confirm its architecture:
uname -m
# x86_64 on Intel/AMD instances, aarch64 on Graviton instancesOn a mixed fleet, this check tells you which kind of host you are looking at.
How Graviton relates to right-sizing
Right-sizing and the move to Graviton are separate changes. Right-sizing changes the size of an instance. Moving to Graviton changes the architecture. If you do both at once and the result is worse, you cannot tell which change caused it.
Common errors
- Launching a Graviton instance type with an x86-64 AMI. Use an Arm64 AMI.
- Assuming a Graviton instance with the same vCPU count and memory behaves identically. Single-thread and multithread behavior can differ, so benchmark.
- Treating "it starts" as "it works". A binary or native library may fail at runtime, or fall back to a slow generic code path.
- Pulling a container image that has only an
amd64variant. The container fails with anexec format error.
Exercise
A team wants to move a Java API from m6i.xlarge to m7g.xlarge. The instance's average CPU is 12%. What should they do first, and why?
Show answer
Right-size first. At 12% average CPU, the instance is probably oversized, so they should check CPU peaks, memory, network and disk, and choose a smaller size on the same architecture. Then they should confirm that every dependency has an Arm64 build, launch from an Arm64 AMI, and benchmark the Graviton instance at the new size. Doing one change at a time makes any regression easy to attribute.
Exercise
You launch a container on a Graviton host and the log shows exec format error. What is the likely cause, and which command confirms the host architecture?
Show answer
The image probably has only an x86-64 (amd64) variant, while the host runs Arm64. Run uname -m on the host. It prints aarch64 on Graviton. The fix is a multi-architecture image or an Arm64 build.