Upgrading a Windows EC2 Instance to a Different Instance Type With Provisioned IOPS

Amazon EC2 just keeps getting better (and cheaper).  They are constantly improving capabilities and tools to make what used to hard easy.

Yesterday, I had to upgrade the test database server as part of a story to improve the performance of our web application.  The DBA had put the database server on a high-memory extra large instance (m2.xlarge) without realizing that that instance type offers what Amazon calls “moderate I/O”.  That instance type has highly variable I/O performance, which caused quite of bit of frustration during demos and tests.  My job for this story was to eliminate the I/O variability so users would see good, consistent performance under normal conditions.  The environment in question is not used for load testing so the server did not have to be sized for full production loads.

My Original Plan

I sketched out the following steps to perform the upgrade:

  1. Backup the databases to S3
  2. Spin up a new extra large instance (m1/xLarge) with support for provisioned IOPS
  3. Setup an EBS volume for the databases with provisioned IOPS and attach it to the instance
  4. Install Windows Updates on the instance
  5. Install SQL Server 2008 R2 and all service packs
  6. Restore the databases
  7. Change the web connection strings to point at the new database server
  8. Test the application.
  9. Change my nightly start and stop scripts to start and stop the new database server (this environment only runs from 7am until 6pm on working days)

I estimated this would take a two to four hours of time. Much of the time would be spent waiting for updates and SQL Server to install.

Faster Upgrade In Place

Before I started, I checked to see if there was an easier way. Thanks to recent improvements in the EC2 tooling, there is.  Here are the actual steps I followed:

  1. Backup the databases to S3 in case something goes wrong
  2. Stop the instance
  3. Record the attachment information and availability zone for the EBS data volume
  4. Upgrade the database instance to m1.xlarge with support for provisioned IOPS
  5. Take a snapshot of the data drive
  6. Create a new EBS volume with provisioned IOPS from the snapshot in the availability zone recorded in step 3
  7. Detach the old EBS volume from the instance
  8. Attach the new EBS volume to the instance using the device and availability zone recorded in step 3

Using this procedure, it took me about 30 minutes to upgrade the server.  Let’s run through the steps in more detail.

Steps in More Detail

  1. Backup the databases to S3 in case something goes wrong

Use SQL Server Management Studio to backup the databases locally.  Zip the backups and use the EC2 Management Console to move the zip to an S3 bucket.

  1. Stop the instance

Select the instance in the EC2 Management Console and use the Action menu to stop the instance.

  1. Record the attachment information and availability zone for the EBS data volume

Select Volumes in the left-hand menu in the EC2 Management Console.  Select your volume and record the zone and attachment information shown in the lower-right portion of the screen.

EC2Figure0

  1. Upgrade the database instance to m1.xlarge with support for provisioned IOPS

Go to the EC2 Management Console, select the instance, pull down the action menu and select “Change Instance Type”.

EC2Figure1

In the Change Instance Type dialog, set the appropriate instance type and check the box to supported provisioned IOPS on the instance.  Press the “Yes, Change” button to upgrade the instance.

EC2Figure2

  1. Take a snapshot of the data drive

Select Volumes in the left-hand menu in the EC2 Management Console.  Select your volume, pull down the Action menu and select “Create Snapshot”.

EC2Figure3

Create the snapshot with a meaningful name.

EC2Figure4

  1. Create an EBS volume with provisioned IOPS from the snapshot in the availability zone recorded in step 3

Select Snapshots in the left-hand menu in the EC2 Management Console.  Search for the name of the snapshot you created in the previous step.  Select the snapshot and click on the “Create Volume” button.  This pops up the “Create Volume” dialog.

Select the desired IOPS level.  Note that IOPS cannot exceed ten times your volume size in gigabytes and must not exceed the maximum IOPS allowed for the instance type (e.g 1000 for m1.xlarge).  For example, the maximum provisioned IOPS for the 40GB drive in this example is 400.  You can increase the size of the volume if you need a greater level of provisioned IOPS.  Windows will see any additional space on the volume as unallocated.

Set the availability zone to the one your recorded from the original volume settings.
EC2Figure6
Press “Yes, Create” to create the volume.

  1. Detach the old EBS volume from the instance

Select Volumes in the left-hand menu in the EC2 Management Console.  Select your old volume, pull down the Action menu and select “Detach Volume”.

EC2Figure7

  1. Attach the new EBS volume to the instance using the device and availability zone recorded in step 3

Select Volumes in the left-hand menu in the EC2 Management Console.  Select your new volume, pull down the Action menu and select “Attach Volume” to bring up the “Attach Volume” dialog.

EC2Figure8

Set the device to the one your recorded from your old volume settings and press “Yes, Attach” to attach the volume

EC2Figure9

%d bloggers like this: