[ARTICLE]

AWS EC2 Instances: Optimizing Your Application Performance

Amazon Web services provide an ever-increasing menu of instance types optimized to fit different use cases. AWS EC2 Instances provide different combinations of CPU, memory, storage, and networking capacity and allow you to match instance performance requirements to the application you plan to run on them. Many, but not all, instance types come in multiple sizes, again allowing you to match or scale the instance to your actual workload needs.

What are AWS EC2 Instance Families?

Let’s have a look at what the AWS “Instance Families” are all about.

General Purpose

These instances aim to provide a balance of CPU, memory, and networking resources that can serve a wide variety of typical applications. A typical web server would be an example of a general-purpose application.

Compute Optimized

These instances are designed for applications that are compute-intensive and would thus benefit from high-performance processors. Applications such as media transcoding, dedicated gaming servers, high-performance computing, and machine learning would all benefit from this type of instance.

Memory Optimized

These instances deliver fast performance for workloads that process large data sets in memory. A big data application that ingests and processes large amounts of real-time data is an example.

Accelerated Computing

These instances use hardware accelerators to perform functions, such as graphics processing or data pattern matching. They do this more efficiently than CPU-based processors target applications similar to those of Compute Optimized instances.

Storage Optimized

These instances work best for applications that require high rates of read-write access to large data sets in local storage. Certain big data applications would fall into this category.

Further Application Optimization With Instance Features

Within Instance Families, some Instance Types have additional features that further allow you to optimize how your application will perform.  Some instances can “burst” CPU performance to meet spikes in workload to prevent application performance impacts. Several storage options are available to balance performance, data durability, and cost. Elastic Block Storage optimization and cluster networking capabilities can further improve performance in applications that benefit from speedy access to data from storage or applications on other instances. Let’s take a closer look at some of these options.

Burstable Performance Instances

AWS has two general types of EC2 instances, Fixed Performance Instances, and Burstable Performance Instances. Because many apps (e.g. small databases, web servers) don’t use a lot of CPU all the time, burstable instances, designated as T instances, provide high CPU performance above a baseline only when needed. The benefit is that you end up effectively paying for smaller instance size, but get the CPU performance of a larger instance when load spikes and it is needed. These burstable instances are only efficient, however, with variable workloads. If your application process needs high CPU performance all the time (think HPC apps, graphics processing,…) a Fixed Performance Instance will provide better ROI.

Storage Options

Amazon provides several storage options that can interface with EC2 instances. Amazon Elastic Block Storage (EBS) is a durable storage volume that attaches to a single, running Amazon EC2 instance. An EBS volume behaves like a physical hard drive and persists independently from the life of an EC2 instance. It can be detached from one EC2 instance and attached to another with the data persisting.

There are three EBS volume types that can be used to balance the cost and performance of your application: two SSD types (General Purpose and Provisioned IOPS) and Magnetic. General Purpose is the default choice for most uses. Provisioned IOPS provides consistent and low-latency performance. These would be appropriate for use with very large databases. Magnetic volumes provide the lowest performance but also the lowest storage cost. If the stored data is accessed infrequently and the cost is a greater concern that performance, this may be an appropriate storage choice.

Another type of block storage is called “instance storage.”  An instance store is on disks that are physically attached to the host computer. This provides temporary storage as, unlike the persistent EBS, instance store data is deleted when the associated EC2 instance is deleted.

Object storage is available to EC2 instances through Amazon S3, a highly available and highly durable storage option. Data is stored as a “blob” or object and unlike EBS stored data cannot be altered in part. Objects in S3 storage need to be retrieved to allow any modification. The modified file can then be returned to S3 storage as a new object. 

EBS-optimized Instances

Some EC2 instances are EBS-optimized to fully use the IOPS provisioned on an EBS volume for an additional hourly fee. Several instance types are EBS-optimized by default  (M6g, M5, M4, C6g, C5, C4, R6g, P3, P2, G3, and D2) and do not incur an additional cost. The EBS-optimized instances are designed for use with all EBS volume types. Amazon recommends using Provisioned IOPS volumes with these types of instances to achieve the best performance. 

Cluster Networking

A small number of EC2 instances have the ability to support cluster networking when deployed in a cluster placement group. This will provide low-latency networking between all instances in the cluster. As long as instances are in the same region and depending on the specific capabilities of the instances, instances can utilize up to 5 Gbps for single-flow and up to 100 Gbps for multi-flow traffic in each direction. 

Measuring Instance Performance

Why measure instance performance?

With so many EC2 instance choices, it is possible to narrow down the ‘right’ instance or set of instance types for an application, but without measuring the actual performance of the application, it is not possible to be sure that you have chosen correctly. 

Amazon recommends measuring your application performance, even running applications on different instance types in parallel,  to make sure that you are using the right instance type. Testing the application’s ability to scale under load is also important to be sure that performance remains consistent and workloads vary in production environments.

Optimizing Amazon EC2 Performance 

While you could start out deploying an application on a General Purpose instance and haphazardly pick an instance size, it is unlikely that you will have chosen the best option for optimal application performance. The point of Amazon’s specific instance type families, instance size options, and added instance features is to make it easier to match your application’s performance needs to the particular capabilities provided by a specific instance type.  Matching your application to an appropriate EC2 instance type and size is a good first step in optimizing app performance.

To go to the next level, you will want, nay need, to monitor your application’s actual performance.  Even if you choose what seems to be the ‘right’ instance, it is possible that limitations in the software, infrastructure, or overall system architecture cause performance issues.  When performance issues are identified, it is then possible to reconsider instance choice and go through the testing process again to validate the new choice. There are many load testing and application profiling tools that can be used to gain the necessary insights.

While this iterative process of testing and adjusting instance type to optimize application performance is critical, it is also slow and laborious.  Further, given possible variations in application performance in relation to production loads and a large number of possible EC2 instance configurations available, achieving truly optimal performance becomes a daunting and potentially never-ending process.  Opsani ML/AI intelligently automates the optimization process and eliminates the toil involved.  In addition to being able to evaluate all available instance options against performance metrics, Opsani can integrate to push the recommended configuration back to your system and validate performance improvements from the changes.  Take continuous optimization with a free trial.