How to Change or Upgrade an EC2 Instance Type

Amazon EC2
Voiced by Amazon Polly

EC2, or Elastic Compute Cloud, is Amazon Web Services IaaS (Infrastructure as a Service) offering – essentially it is a service for running virtual machines in the AWS cloud.  I wrote an earlier post about EC2 and all the different instance types titled AWS EC2 – Everything You Need To Know About EC2 Instances which touched on some of the pre-requisites for changing EC2 instance types – I’ll cover that again here and then take a deeper dive on how to actually go about changing instance type.

Why Change ec2 instance type?

There are a number of reasons that you may wish to change an EC2 instance running in AWS.  Here are some of the most common:

  • Increase resources – perhaps you need more CPU, RAM or network throughput due to increased application demand, which hopefully is a good thing!
  • Decrease resources – perhaps you want to rightsize for cost optimization purposes by removing any underutilized resources.
  • Change of workload type – if the workload on the EC2 instance has changed from, say, CPU instensive to RAM intensive, it may be more efficient to change to a different instance family more suited to the new workload. 
  • Migrate from previous generation to current generation instance type – AWS frequently update their instance families, and often newer generation instances offer higher performance at a lower cost.

Changing EC2 Instance – Pre-requisites

If you decide that you need to change instance type for performance or cost management reasons, you can simply resize it to another instance type as long as:

  • Virtualization type is the same – PV (paravirtual) or HVM (Hardware virtual machine) – EC2 uses both virtualization types and it is not possible to change an instance from one type to the other.
  • CPU Architecture is the same – there is limited support for 32 bit AMIs, Arm processors etc – you cannot switch from an Intel CPU instance to an AMD CPU instance, for example.
  • Network is compatible – newer instances need to be in a VPC, so EC2 classic instances can’t be resized to a newer instance type if not in a VPC.
  • Root Storage is an EBS volume – if your root volume is instance store based (on ephemeral storage), you’ll need to migrate your application to the new instance type.
  • Enhanced Networking Drivers are installed – if the new instance type supports advanced networking features, you’ll need to install the drivers before re-sizing.
  • NVMe Drivers are installed – for instances that support NVMe (Non-Volatile Memory Express) SSD instance store volumes.

Upgrade or Resize EBS Backed EC2 instance

If the EC2 instance you want to change has an EBS (Elastic Block Store) root partition, you can simply change or ‘resize’ the instance.  The instance type that you want to resize to must be compatible with the current instance type, otherwise you will need to create a new instance and migrate your apps and data to the new instance (see next section for details on how to do this).

In order to resize an EBS backed instance you must first stop the instance.  When stopping or starting an EC2 instance you need to be aware that:

  • The instance will be moved to new hardware, but the instance ID will not change.
  •  The instance will retain any associated Elastic IP Addresses, private IPv4 and any IPv6 addresses, but if it has a public IPv4 address this will change.
  • If the instance is part of an Auto Scaling group, you may wish to disable the scaling processes while resizing the instance, to prevent it from being terminated due to being marked as ‘unhealthy’.
  • You should plan for downtime when the instance is stopped – you may need to schedule a maintenance window as the process can take several minutes, plus you should plan for any unforeseen problems.

 Follow these steps to resize your EC2 instance in the AWS Console:

  1.  Install any drivers required by the new instance type onto the current instance (NVMe drivers, enhanced networking drivers)
  2.  Open the EC2 console and choose instances from the navigation pane:EC2 Console
  3.  Select the instance and then select ‘Actions, State, Stop’:Stop EC2 Instance 
  4. Choose ‘Yes Stop’ in the dialogue box:Yes Stop EC2 Instance
  5.  Ensuring that the instance is still selected, choose ‘Actions, Instance, Settings, Change 
    Instance Type’:Change EC2 Instance Type
  6. In the dialogue box that appears, there isa drop down menu that will only display compatible instance types – if the instance type you want is not displayed, you cannot resize to this instance type.  If the instance type you are switching to supports EBS-optimization, you can select it in the check box to enable: Change EC2 Instance Type Dialogue
  7.  Restart the stopped instance by selecting ‘Actions, Instance State, Start’, then choose ‘Yes Start’ in the dialogue box that appears.  The instance can take a few minutes to reach the ‘running’ state.

Change Instance Store backed EC2 Instance Type

The process is a little more complicated if you want to change the instance type of an Instance Store backed EC2 instance type.  It is not possible to simply change the instance type – you must migrate to a new instance type by creating an image of the existing instance and launching a new instance of the desired type from the image.

To migrate an instance store backed instance, follow these steps:

  1.  Create a backup of any data on the instance store volumes to persistent storage.  For any attached EBS volumes, you can either take a snapshot or detach the volumes from the instance to be reattached to the new instance once created.
  2. Create an AMI of the instance store backed instance.  Follow the instructions here to create an Instance Store backed Linux AMI 
  3. In the EC2 console, find the AMI you just created:AMI
  4.  Select the AMI that you wish to use and choose ‘Launch’:Launch AMI
  5.  Specify the instance type you want in the launch wizard – if you can’t see the instance type you want then it is not compatible with your AMI:Launch Wizard
  6. Terminate the original instance if it is no longer required.

Which EC2 Instance Type Do I need?

If you know you need to change your EC2 instance type, but you are unsure which instance type to select from the dazzling array of almost 300 instance types, fear not, you are in luck.

AWS Compute Optimizer is on hand to provide recommendations to help with improving performance, saving money, or both

Compute Optimizer analyses existing EC2 instance specifications and utilization metrics.  By comparing the data, it will recommend which EC2 instance types are best suited to your workloads.

Compute Optimizer recommendations fall into the following categories:

  • Under-provisioned – you may need more CPU, RAM or network throughput so need to upgrade.
  • Over-provisioned – you have too much CPU, RAM or network throughput, so you can safely downgrade.
  • Optimized – everything is just right
  • None – there are no recommendations for the instance, perhaps because there is not enough data, or the instance type is not yet supported by Compute Opitmizer.

 Although Compute Optimizer is free to use, you must first opt in to start the collection of data on which the recommendations will be based.  It may take up to 12 hours before any data or recommendations are available.

Once Compute Optimizer has made recommendations, you can find them in the EC2 console by selecting and instance, then in the ‘Details’ tab, under ‘Finding’:

Compute Optimizer Recommendations

The recommendation will display the suggested instance type along with the hourly on-demand price for the recommended instance.

So there you have it.  AWS has the tools to help you select the appropriate instance type from a huge list of options.  If this all still sounds a little overwhelming, Logicata are here to help.  Check out our AWS Managed Services – we’re routinely optimizing EC2 instances for our clients while minimizing downtime, so perhaps we can assist you too!

You Might Be Also Interested In These...

rainy window

Why do I need a Public Cloud Managed Service Provider?

This is a question posed by businesses we speak to – why do I need a Public Cloud Managed Service Provider like Logicata? Why can I not just manage my own cloud? Why should not just deal directly with AWS and Azure and do it all myself? And the answer of course is yes – […]

View Post
Outbreak and lockdown city on covid 19-virus epidemic in europe zone.healthy and medical treatment.biology and economy.

Combat Covid-19 With 3 Free AWS Homeworking Solutions

It’s fair to say that the world was unprepared for a global pandemic such as Covid-19.  We’ve seen outbreaks in the past – SARS, Ebola, but nothing that has spread so quickly and with such far reaching consequences.  Bill Gates told us in 2015 that we were not ready for such a global outbreak and he was […]

View Post
AWS Wall

AWS EC2 – Everything You Need to Know About EC2 Instances

EC2 is short for Elastic Compute Cloud, and it is Amazon Web Services IaaS (Infrastructure as a Service) offering, enabling developers to gain easy access to compute resources in the AWS cloud. AWS offer 275 instances all with set configurations of CPU, RAM, storage type and network performance.  They are grouped into categories of instance […]

View Post
ebook featured image

5 Steps to a Successful

AWS Migration