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:
- Backup the databases to S3
- Spin up a new extra large instance (m1/xLarge) with support for provisioned IOPS
- Setup an EBS volume for the databases with provisioned IOPS and attach it to the instance
- Install Windows Updates on the instance
- Install SQL Server 2008 R2 and all service packs
- Restore the databases
- Change the web connection strings to point at the new database server
- Test the application.
- 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:
- Backup the databases to S3 in case something goes wrong
- Stop the instance
- Record the attachment information and availability zone for the EBS data volume
- Upgrade the database instance to m1.xlarge with support for provisioned IOPS
- Take a snapshot of the data drive
- Create a new EBS volume with provisioned IOPS from the snapshot in the availability zone recorded in step 3
- Detach the old EBS volume from the instance
- 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
- 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.
- Stop the instance
Select the instance in the EC2 Management Console and use the Action menu to stop the instance.
- 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.
- 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”.
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.
- 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”.
Create the snapshot with a meaningful name.
- 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.
Press “Yes, Create” to create the volume.
- 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”.
- 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.
Set the device to the one your recorded from your old volume settings and press “Yes, Attach” to attach the volume
You must be logged in to post a comment.