How can I improve the CPU performance of my Amazon EC2 Linux instances?

3 minute read
0

I want to improve the performance of my Amazon Elastic Compute Cloud (Amazon EC2) Linux instances.

Resolution

Use HVM AMIs

To improve your performance, use hardware virtual machine (HVM) Amazon Machine Images (AMIs). HVM AMIs allow you to use newer instance classes and Amazon EC2 features such as enhanced networking. For more information, see Linux AMI virtualization types.

Turn on enhanced networking

If your instance type supports enhanced networking, then you can use this feature to improve CPU performance without any additional costs. Enhanced networking uses single root I/O virtualization (SR-IOV) to provide higher I/O performance and lower CPU utilization than traditional virtualized network interfaces. For supported instance types and instructions, see Enhanced networking on Linux and Enhanced networking on Windows. To turn on enhanced networking, your instance must use an HVM AMI. Also, you must launch the instance in an Amazon Virtual Private Cloud (Amazon VPC).Note: It's a best practice to use the updated version of the Elastic Network Adapter (ENA) or the Intel 82599 Virtual Function (VF) interface driver.

Use NVMe volumes

For storage, use non-volatile memory express (NVMe) instance store volumes to improve performance. Depending on your kernel version and instance type, performance with NVMe volumes might vary with workload. For more information, see Amazon EBS and NVMe and SSD instance store volumes.

Note: To use the Kyber I/O scheduler for certain workloads, be sure that your Amazon EC2 Linux instance runs kernel 4.12 or newer.

Use HugePages

HugePages can improve performance for workloads that deal with large amounts of memory access. For more information, see the HugePages documentation on the kernel.org website. For best practices for high-performance computing (HPC) workloads, see High performance computing lens.

Use the latest kernel version and instance types

It's a best practice to use the latest kernel version and instance types. If you use M3, C3, or other older instance types, then migrate to a newer instance type, such as M7, to improve your performance. Also, use the latest available kernel version for your operating system (OS). For more information, see Amazon EC2 instance types.

Use jumbo frames

When possible, avoid small packets. If your workload supports the use of larger packets with jumbo frames, then use this configuration. For more information, see Network maximum transmission unit (MTU) for your EC2 instance.

Use DPDK

To move networking outside of the kernel and into the userspace, use Data Plane Development Kit (DPDK) software. DPDK might require a software update that includes DPDK support. For more information, see the DPDK website.

Turn on PCID

If you turned on kernel page-table isolation (KPTI) on your instance's OS, then also turn on the process context identifier (PCID) feature. To use this feature, verify that both the kernel and the instance type support PCID.

Scale your instances

Increase the size of your instances, or increase the number of instances.

Use timers

The timestamp counter (TSC) timer is generally the best performing timer that's available to most instances. If you use a xen timer, then you might see improved performance when you switch to a TSC timer. If you use an older OS with a jiffies timer, then move to an OS that supports xen or, preferably, TSC.

Note: Older instance types, such as M1 or M2, provide an emulated TSC timer. For better timer performance, move to a newer instance type, such as M7.

Related information

Best practices for Amazon EC2

AWS OFFICIAL
AWS OFFICIALUpdated 5 months ago