Home » Running SQL Server Databases in the Amazon Cloud (Part 1)

Here, I have created a parameter group for SQL Server 2012 Express Edition (shown as sqlserver-ex-11.0). Some of the parameters, like xp_cmdshell or “show advanced options” can’t be changed.

Option Groups in Amazon RDS for a Database Instance

Option Groups are used to specify further features and options for an RDS database instance. At the time of this writing (May 2014), AWS can host four types of database engines in RDS: Oracle, Microsoft SQL Server, MySQL and PostgreSQL. Option groups don’t have much use for SQL Server instances unless you want to use Transparent Data Encryption (TDE). Despite any performance penalty for implementing TDE, this could be one requirement from your management team if you roll out a SQL Server “out there in the cloud”. TDE is the only option you can specify for a SQL Server option group. You define the option group the same way you define a parameter group (as shown above).

Storage Options for SQL Server on Amazon RDS

A major bottleneck for most SQL Server database performance is the underlying storage: whether you are running it in a physical box, a SAN or Direct Attached Storage. AWS addresses this problem by offering two types of storage: Standard and Provisioned IOPS.

Standard storage is what you would find with traditional Network Attached Storage. RDS uses these storage volumes as virtual hard drives in the network. When you work with standalone servers in AWS (EC2 instances), you can attach and detach these standard storage volumes to your machines much like your storage engineers would provision them from a SAN and carve out a volume for your server. With standard storage if you have no control over the I/O performance of the disk subsystem.

The second class of storage is called Provisioned IOPS (Input Output per Second). With this type of storage, you define the number of IOPS rate and storage size when you create your SQL Server instance and AWS will provision the appropriate storage behind the scenes to meet the requirements. This is all possible due to the nature of the cloud itself. The whole concept of cloud computing is to run your computing, storage and networking components in a virtualized world where the complexity of the physical infrastructure is largely hidden from you.

With provisioned IOPS, each read or write activity is considered a single I/O operation and the I/O size for AWS Provisioned IOPS is 16 KB. That means AWS considers each 16 KB request as one IO. With SQL Server, the database page size is 8 KB, which is half the size of the AWS IO.

Provisioned IOPS storage obviously costs more, but AWS recommends you use it for RDS database instances to deliver fast, predictable performance. Even with that, storage performance can still be less than optimal if the underlying instance class is not sufficiently powerful. We will talk about instance classes in the next section.

Instance Classes Explained on Amazon RDS for SQL Server

When you rollout servers (whether physical or virtual) in your on-premises network, you are more-or-less in control: you can specify the number of CPU cores and processor model, number of drives and their sizes and ask for sufficient amount of memory, connect the server to high speed network switch and so on.

With Amazon Web Service much of that physicality is gone: you are no longer in charge of asking for what you need. Instead, you are given the option of choosing from a range of “instance classes”, each class with different types of characteristics. For example, you can roll out a t1.micro instance: one with only half gig of RAM and very low network speed. Or you can specify an m2.4xlarge instance: one with extra CPU power, 68 GB RAM and 1000Mbps network connectivity.

Why is it so? Why have they taken away your rights as a DBA? Well, that’s because the underlying hosts, virtual machines, networks and storage that powers your DB instance are not always fixed. It could be running in a different network, have storage allocated from a different storage pool and hosted in a different virtual machine every time it starts up. How do you standardize the performance of a machine in such case? One way is to benchmark the overall computing power of a machine and classifying it. That’s exactly why you have different pre-configured instance classes. It doesn’t matter where your VM is running: it could be running in one physical host with one type of processor in its “on” state. You stop and restart the instance and the VM could be running in a completely different host with a different CPU power. With the instance class model the VM will always start with the same CPU and memory capacity it was rolled out with – no matter what difference lies in the underlying infrastructure.

With AWS RDS, different types of instance classes are available for different versions and editions of SQL Server. Some instance classes come with high network speed while others have dedicated IO channels for storage. Amazon recommends using the latter class of instances with provisioned IOPS storage.

Let’s Create a New RDS for SQL Server

Now we have covered some of the basic concepts, it’s time for the exciting stuff: roll out our brand new RDS instance and connect to it.

You access the RDS dashboard page from the AWS main menu, as shown below. Make sure you have chosen the Region where you want your database instance to reside. You can choose the Region from the upper right corner of the Management Console.

AWS Management Console Main Menu

Clicking on the RDS link takes you to the RDS Dashboard page:

RDS Dashboard Page

Next, let’s click on the “Launch a DB Instance” button. This will start the wizard.

In the first screen, choose a database server platform. As you can see from the image below, there are a number of SQL Server options available. At this moment, RDS supports:

  • SQL Server 2008 R2 (Express, Web, Standard and Enterprise Edition)
  • SQL Server 2012 (Express, Web, Standard and Enterprise Edition)
Available RDS Database Engines

In this example, we chose to use sqlserver-se (Standard Edition).

Please note that it’s not eligible for free tier usage and you will incur a charge per hour of instance usage. I am choosing this so all other options can be viewed in subsequent screens. Once you have followed all the steps and can connect to your new database instance from client application, you can delete the instance to minimize costs. Don’t keep it running unless you have to.

What you see in the next screen will depend on which Region you have chosen for the RDS instance. RDS offers a feature called the Multi-AZ deployment. This used to be an option for other database engines like MySQL, Oracle or PostgreSQL, but Amazon has recently announced the Multi-AZ support for SQL Server. 

What Multi-AZ does is that when you roll out your SQL Server database instance, another instance is provisioned for you in another Availability Zone in the same Region. That instance acts as the “standby replica” of your primary database instance. All database transactions against your primary DB instance are synchronously applied to the standby replica, effectively storing a secondary copy of your data. You can’t access the standby replica as it’s used for disaster recovery purpose only. In the event your database server crashes or an Availability Zone fails, AWS will promote the standby replica as the primary DB instance and start servicing database traffic from there. It all happens transparently behind the scenes; you don’t have to do anything as a DBA. Multi-AZ deployment can be useful in certain cases: for example, if you choose to upgrade your DB instance version, AWS will failover to the standby replica during the process. AWS RDS offers Multi-AZ support for SQL Server through Database Mirroring.

At the time of this writing, the only Regions that offer Multi-AZ deployment support for SQL Server is EU and US West (Oregon). This will obviously change in the future, so if you are creating your database instances in any of these Regions, you would see the following screen: Choosing Multi-AZ Deployment and Provisioned IOPS

Note the suggestion made by Amazon. They suggest you use Multi-AZ deployment and provisioned IOPS storage for production systems. Also, they don’t come free. Configuring Multi-AZ deployment requires additional configuration in your VPC network, one which needs to be done before you run the wizard. Fortunately this configuration is already done for the default VPC.

Clicking on the Next Step button will take you to the DB Instance Details page. There are quite a few options you can choose here:

First of all, you can choose your licensing model. There are two licensing models available for SQL Server in RDS. One is “license included” and the other one is “bring your own license (BYOL)”. In the first model, Amazon holds the SQL Server license for the RDS instance. Its cost is included in your RDS pricing. This is a good choice if you don’t want to get into the hassle of purchasing licenses and so on. You pay extra, but you know you don’t have to worry about licensing.

With the second option, you are eligible to use the license of the existing on-premises SQL Server being migrated to RDS. This is applicable to volume licensing customers with appropriate software assurance coverage. I am by no means a software licensing expert, but this is what Amazon states. You may wish to check with your own software licensing team when you roll out.

Also, as an AWS customer, you are restricted to 40 SQL Server DB instances in RDS. Of these, only 10 can be used in the license-included model. The existence of a stand-by replica will also count in those licenses. Also, license included model is not available for Enterprise Editions of SQL. Choice of Licensing Model

Next, you have the option of choosing between SQL Server 2008 R2 and 2012 as your SQL Server version. I am sure with time SQL Server 2014 will also be made available. In this example, I have chosen to install a SQL Server 2012 standard edition instance. Choice of DB Engine Version

Next comes the instance class. What you see in this section depends on the version and edition of SQL Server you have chosen. To keep costs to a minimum, I have chosen an m1.small instance class. According to the RDS documentation, this instance class translates to 1 CPU and 1.8 GB of RAM. Choice of DB Instance Class

Next, we choose Multi-AZ Deployment: Yes (Mirroring). Choice for Multi-AZ Deployment

The option button for auto minor version upgrade is enabled by default. This tells us that AWS will automatically apply security patches, cumulative updates and service packs for this instance as they become available. Some of these “upgrades” require a downtime and that’s another reason to use Multi-AZ deployment. In Multi-AZ deployment, AWS RDS will apply the patches to the standby replica first, failover to the patched replica, promote it as the primary instance and then apply the patch to the original instance (which becomes the new standby). Choice of Auto Minor Version Upgrade

In the next field, RDS asks how big your database instance should be. For m1.small instance class, it lists the minimum size as 200 GB. The maximum total size of an RDS SQL Server instance can be 1 TB. The instance can host up to 30 databases. This may sound like a limitation and in my opinion it is and we will discuss this in the next tip. But for now, let’s accept the default size. Choice of Storage Size

The checkbox for provisioned IOPS is turned off at the moment, so we turn it on, and another field becomes visible asking about the IOPS rate. Note the two messages from RDS:

Choice of Storage Class

The first one tells us that the ratio between IOPS and storage size is 10. This means that if we have chosen our database instance size (total size of all databases to be hosted in this instance) as 200 GB, the minimum IOPS we need to specify is 2000. And also if we need to increase the IOPS, the next value should be 3000, 4000 and so on. So in this case we choose the following values: Choice of Storage Class, Storage Size and IOPS

One thing you need to be aware of – and again we will discuss it in the next tip – is the allocated storage for SQL Server RDS instance can be specified only once during setup and can’t be modified later. You can change the instance class and go higher (vertical scaling), but that will only increase CPU and RAM capacity not the storage size. This means you need to allocate the maximum amount of storage you think your instance will ever need. And as mentioned before, this can be specified up to 1 TB. Personally, I think it’s a major drawback, but AWS says this is due to the extensibility limitations of striped storage attached to Windows Server.

Next, we are asked for a database instance identifier, a master user name and master user password. The database instance identifier is not what your named SQL Server instance would represent: this is just an identifier for AWS. In our example, we have given it a name and specified sa as the master user: Choice of DB Instance Identifier and Master User

At the end of the first phase, we have the first page of the wizard looking like this: DB Instance Details

Clicking the Next Step button takes us to the section where we specify additional parameters. This is about where we want to place our RDS instance, what port we would use, what parameter group and security group need to be assigned, etc. The image below shows these fields: Additional Configuration

The choices we have made in this screen are simple:

We are almost there; before it’s all wrapped up, we need to tell RDS whether we need to have our databases backed up. When you click the Next Step button, the Management Options screen is shown. Management Options

The fields in this screen are fairly self-explanatory. We have chosen to enable automatic backup of the database instance. With automatic backup enabled, RDS will make a full backup of the databases every day. Transaction log backups are enabled also. The backups are held for a duration you can specify. It’s called the retention period. With RDS, retention period can be up to 35 days. With full database and transaction log backups enabled, you can use RDS to restore the instance up to last five minutes within the specified retention period.

You can choose when your instance gets backed up. You can specify the time in UTC format or leave it to its default value (“No Preference”). With the “No Preference” the backup window will be chosen by AWS and it will assign a random 30 minute backup window within an 8 hour block of time allocated for your Region. What this means is that AWS will initiate the backup anytime during an 8 hour period that’s been pre-allocated for your AWS Region.

The same concept holds for the maintenance window. Maintenance happens weekly and again you can either specify your own time slot or leave it to AWS. Bear in mind that this “maintenance” is not the regular DBCC checks and index reorganizations you would have scheduled for an on-premises database server. AWS applies changes to an instance during maintenance window; this includes applying patches, upgrading instance classes, etc. For individual database maintenance, you will still need to run your jobs and scripts.

Clicking on the Next Step button will show the final screen of the wizard. This gives you a chance to review the options you have chosen so you can go back and modify them if necessary.

Review Page

Click on the “Launch DB Instance Page” and RDS will start the process of rolling out the server for you. You will be presented with an information page like the following: RDS Database Creation Status

Click on the “Close” button and we are transferred back to the RDS Instances page in the Management Console. The initial status of the RDS instance is shown as “creating” RDS Instance Creating

We will wait till the status changes to “available”. This can take a while though (as two instances are created). Once the instance status is “available”, expanding the arrow on the left side gives us more information.

RDS Instance Endpoint

The most important part of this screen is the Endpoint. That’s the address of the SQL Server instance you have just installed. It’s not an IP address, nor a simple host name like you would see in your on-premises network, rather a DNS CNAME. That’s because the IP address of the DB instance can change behind the scenes when it fails over to the standby replica. Amazon does not want you to manually reconfigure your client application to point to the failover instance. As long as the CNAME (Canonical Name) is used, AWS will translate it to the correct IP address of the running database instance.

Also, the string ends with the port number of the SQL Server instance (1433) separated by a colon (:). When you use Management Studio to connect to the instance, you need to replace that colon with a comma (,).

Another thing to remember: if you are accessing the instance from within your corporate network, talk to your network administrators to allow egress traffic through the firewall. You are connecting to a SQL Server instance in the Internet on port 1433: you need to tell them about the port and you need to give them the endpoint CNAME. You have already configured the DB instance’s firewall traffic rules through security group; the same type of configuration needs to happen at your end.

The following image shows my SQL Server Management Studio connected to the instance. As a side note, the database rdsadmin is created by default by RDS and I recommend you don’t delete it.

RDS SQL Server Instance Connected from Management Studio

If you have been able to follow up to this point, you should explore the instance, see what options are available for SQL Server, what configuration values you can change or what commands you can run.

Conclusion

In this tip you have seen how you can create an Amazon Web Service RDS SQL Server instance and connect to it from your local workstation. However, RDS is not the “all-size-fits-all” answer to your applications’ answer to all your application’s database needs. It has its limitations and in our next tip we will talk about those limitations.

Next Steps