I want to change my Amazon Elastic Compute Cloud (Amazon EC2) instance type to a different family and hypervisor type.
Resolution
Verify your instance compatibility and requirements
Compare the specifications of your current instance type and the instance type you want to switch to. Review the following factors for each instance type:
- CPU architecture, such as Intel, AMD, or Arm-based
- Virtualization type, such as Nitro or Xen
- Network performance capabilities
- Storage optimizations, such as Amazon Elastic Block Store (Amazon EBS)-optimized EBS volumes or instance store
- Accelerator support, such as GPU or FPGA
Instances within the same family or that use the same hypervisor are more likely to be compatible. However, variations in hardware specifications or features might affect compatibility. For more information, see Compatibility for changing the instance type.
For example, if you migrate from an m4.large (Xen) instance to an m5.large (Nitro) instance, then make sure that your AMI and kernel support the Nitro enhanced networking Elastic Network Adapter (ENA). Only later instance types, such as m5 and c5, use Nitro. Earlier instance types, such as m3 and c3, use Xen virtualization.
Create an AMI backup
Create a backup Amazon Machine Image (AMI) of your existing EC2 instance. If you experience compatibility issues during or after the instance type change, then you can use the AMI to roll back to the previous instance.
Update a test instance
Use the AMI to launch a test instance with the new instance type to validate compatibility and identify issues before you update your production environment.
On the test instance, thoroughly test your applications, services, and workloads to make sure that they function as expected with the new instance type. Monitor the resource usage, and monitor the instance, networking, storage, and application performance.
To identify potential issues, check for missing driver errors in dmesg or /var/log/syslog. Access the instance, and then run the following commands to validate the key instance functions such as networking:
# ping google.com
# curl -I http://example.com
To check your storage for issues, take the following actions:
-
To verify that the instance can detect your disks, run the following command:
# lsblk
-
To check for NVMe errors, run the following command:
# dmesg | grep -i nvme
To test your instance performance, take the following actions:
-
To simulate CPU load, run the following command:
# stress --cpu 4 --timeout 60s
-
To check available memory, run the following command:
# free -h
For example, if you move from a c5.large (Nitro) instance type to a c6i.large (Nitro, newer Intel Ice Lake) instance type, then the change is successful. However, if you move from a m4.xlarge (Xen) instance type to a m6i.xlarge (Nitro) instance type, then you might experience issues. To resolve the issues, update your ENA drivers. For more information, see Activate enhanced networking on your instance.
Update the production instance
To update the production instance, use one of the following methods.
For non-critical workloads with maintenance windows, change the instance type in the Amazon EC2 console.
Important: Before you change the instance type, review the effects that stop and start has on your instance.
For production workloads that need minimal disruption, complete the following steps to launch a replacement instance:
- Launch a new instance with the updated instance type.
- Attach the previous instance's EBS volume. Or, restore the new instance from the EBS snapshot.
- Update the DNS, load balancer, and Amazon Route 53 records to point to the new instance.
For stateless, scalable applications, complete the following steps to refresh the Amazon EC2 Auto Scaling Group:
- Update the Auto Scaling group launch template with the new instance type.
- Start an instance refresh to gradually replace the previous instances.
Monitor the production instance for issues
To review your driver and kernel modules, run the following command:
# modinfo ena
To check your NVMe storage, run the following command:
# nvme list
Note: To run the nvme command, you must install the nvme-cli package. To install nvme-cli, run the following command based on your distribution:
Debian and Ubuntu:
sudo apt-get install nvme-cli
Red Hat Enterprise Linux (RHEL) and CentOS:
sudo yum install nvme-cli
Fedora:
sudo dnf install nvme-cli
Arch Linux:
sudo pacman -S nvme-cli
To monitor the performance and stability of the instance, check the CPUUtilization, NetworkIn, and NetworkOut for Amazon CloudWatch metrics. Use the metrics to monitor CPU usage and network bandwidth.
If you experience issues, then use the backup AMI to roll back to the previous instance state.
Related information
Amazon EC2 instance type changes
Create an Amazon EBS-backed AMI