Tag Archive: ec2

SQL Server in EC2

The cloud is robust and reliable. The cloud solves all of our scaling needs. The cloud makes my poop smell like roses. While all of these statements are theoretically true it takes some effort to make them true in reality, especially when a database is involved.

Who Is Deploying SQL Server in EC2?

A question I hear a lot is, “Who is putting SQL Server into EC2?” Sometimes there’s a hint of incredulity in that question, hinting that people can’t seriously be deploying SQL Server into EC2. That’s far from the truth: many companies, large and small, are deploying SQL Server into Amazon’s cloud, with varying degrees of success.

Back to the question of who’s deploying SQL Server in EC2…

I work with a start up building a platform on a Microsoft stack. The front end is hosted on mobile devices, the middle tier is written in .NET, and the database is SQL Server. They’re just starting out and they don’t have the time to spend speccing out servers, ordering them, and waiting for delivery. It’s easy to spin up servers to test new features and functionality and if a feature doesn’t catch on the servers are turned back off. Traditional hosting facilities didn’t offer the the flexibility or response times that they were looking for, so they chose Amazon EC2.

Another company I work with is a ISV transitioning to a Software as a Service (SaaS) model. The ISV works in an industry where there is a lot of specialized knowledge and technical ability, but that knowledge and ability doesn’t have anything to do with keeping a server up and running. In the past they’ve added additional maintenance routines to the software that they sell to customers, but sometimes customers don’t have anywhere to host this mission critical software. The ISV has hosted a few customers on their own servers, but they don’t want to keep buying new hardware in response to customer demands – what happens when a customer leaves? The ISV hasn’t made the move to cloud computing yet, they’re feeling out the different options available, but EC2 provides a level of flexibility that they won’t get through traditional IT solutions.

What are some of the problems?

There are, of course, problems with every way that you can possibly deploy SQL Server. When you deploy on premises, you have to purchase hardware, wait for it to arrive, set it up, and then you have to maintain it. When you host your database with another hosting provider, you’re limited by the amount of server space they have available. When you host in EC2 there are a different set of problems.

Cost

One of the perceived problems with deploying into the cloud is the cost. You’re renting something by the hour (like that “friend” your uncle brought to Thanksgiving last year); and renting something by the hour can get really expensive when you want that something to be up and running all the time.

How much would it cost to keep a reasonable SQL Server running 365 days a year? $10,862.40 assuming that you’re using a Double Extra Large Hi-Memory instance (that’s 4x 2.61GHz Xeons with 34.2 GB of memory). You can really kick out the jams and get yourself a Quadruple Extra Large Hi-Memory instance (8x 2.66 GHz Xeons and 68.4GB of memory) for twice the price. Yeah, that’s expensive. Of course, you can also reserve the instance and just buy it outright for a fraction of that cost, but who wants to do that?

What would a similar server cost you from HP? You can get an HP ProLiant DL380 G7 with a pair of fancy pants Intel E5640 CPUs (that’s right around the same speed as the EC2 instance), 32GB of RAM, and 1.2TB of in chassis storage for about $8,600. That price doesn’t include an OS or any other licensing costs. It also doesn’t include power, cooling, or even a spare server sitting around ready to pick up the load if your primary server fails.

Storage isn’t tremendously expensive in Amazon’s cloud – 10 cents per GB per month of provisioned storage. Over the course of a year, 1 terabyte of storage is only $102.40 a month, and that storage is fairly redundant within a single data center.

Despite the cost, Amazon’s cloud is still incredibly popular with many businesses. Why? Simple: it’s easy to start with a small amount of resources and rapidly scale in response to customer demands. If something doesn’t pan out, you just stop the servers and delete the storage and you don’t have to worry about it anymore. The costs go away as soon as you stop using the compute cycles.

Noisy Neighbor

I used to live in an apartment. It wasn’t a great apartment. In fact, it wasn’t even a nice apartment. I could hear everything that my neighbors did. After a while, I knew about their girlfriends, their love of Super Tecmo Bowl, and I learned that they liked to listen to loud music on week nights when they didn’t have to work the next day.

My noisy neighbors made it difficult for me to get things done. When you’re sharing a host, noisy neighbors can make it difficult to get things done, too. This sort of thing can happen on a server right now – when one program is aggressive writing to disk, read performance will suffer. If you’re sharing a physical server with another guest operating system, you have no idea what that other OS is doing. It could be sitting there doing nothing, it could be chugging along doing 3d rendering, or it could be a BitTorrent server. You have no idea what’s going on in the next room and how it could be affecting your performance.

Unfortunately, there’s not a lot that you can do about noisy neighbors apart from moving. In the real world, you move to a new apartment or buy a house. It takes time and money to get a new place, but it’s feasible. In EC2 it’s a lot easier to get a new place: you just upgrade your instance. You pay more by the hour, but it’s easy to get a bigger place.

Crashes in general

To be fair, you can’t do much about crashes if you’re using someone else’s hosting service; when the data center loses power your server is going to go down. So, how do you protect yourself from crashes? Redundancy, of course.

Unfortunately, redundancy gets expensive fast. If you want a redundant mirror for that 10k a year server, you need a second 10k a year server. If you want multiple servers spread across the country, you’re paying for each one. Thankfully the cost of the servers includes the Windows license, but it’s still a large cost for many people to stomach.

SQL Server has a number of options to help you keep your servers up and running in case something horrible happens. Traditional database mirroring will work in EC2. You are free to implement whatever Rube Goldberg machine you want. It’s important to keep in mind that you have little control over your storage (there are no SAN snapshots or SAN mirroring that you can control) and there is no dedicated network that you can rely on. All of your connectivity goes over the open infrastructure within Amazon’s data centers. You’re fighting for bandwidth with Amazon, Netflix, Heroku, and everyone else in the cloud.

Limits: Number of Drives

How many drives can you connect to an installation of Windows locally? 26 or so, right? That’s how many letters there are in the alphabet. You can go beyond that using mount points to boost the amount of storage you have. For most purposes, though, you effectively can attach an unlimited number of drives to a Windows machine. Certainly more than you’ll need. SANs make it easy to create huge volumes, after all.

In EC2, that’s not quite the case. You can only attach 16 drives (Amazon call them volumes) to a server. It’s important to keep this limitation in mind when designing your strategy to move into Amazon’s cloud. If you need to store more than 16 terabytes of data, you’ll need to find a way to spread that data out across multiple EC2 instances. Considering some of what we’ll cover later on, this is going to be a really good idea.

Limits: Network Throughput

Did you know that there’s a pretty solid limit on network throughput in EC2? I didn’t either until I start performing some storage benchmarks (more on this soon). It turns out that there’s a single active gigabit connection into each host. That’s right: a gigabit connection per host. You might be sharing that server with a lot of other servers. If there are 4 other SQL Servers sharing the same gigabit connection, you could end up with some very poor performance.

Amazon recently added instances with 10 gigabit network cards, but they’re limited to Linux machines in the US-East region right now. In the future there might be instances with 10 gig connections that run Windows, but there’s nothing in EC2 right now to make the path between a Windows server and the storage any faster. To keep up to date on which instances have 10 gigabit ethernet, visit the list of EC2 Instance Types and search for “I/O Performance: Very High”.

In short, if your applications are chatty, you’re going to need to learn to break them apart into many smaller pieces to keep throughput high.

Limits: Instance Sizes

We just briefly touched on this in the last section – not every size of instance is available in every region. Typically, the US-East region gets the newest fanciest servers, at least as far as I can tell. Other regions slowly get new hardware over time. The name of the instance type (m1.small, m2.4xlarge) will stay the same over time, but it may not be possible to bring up instances of the same size in every region.

Performance: Instances

Just like any other computer, there are a finite number of resources available on any host. Likewise, the VMs that you spin up have a finite amount of resources available to them. Unlike your local data center, you have no control over which VMs share the same host.

Normally you could put different machines together and stagger their functionality around the clock so that guests that did bulk processing at night would be on the same host as machines that record orders during business hours. When everything is under your control, it’s very easy to make sure that any host isn’t overcommitted during a certain time window.

The only way that you can guarantee performance is to allocate larger instances that take up all of the physical resources of the host but cost more. By doing this you’re able to eliminate the effect of noisy neighbors. It’s important to understand how to get the best performance out of your resources.

Performance: Storage

If you want to keep data around for any length of time, it’s important to persist it somewhere. Persisting your data means that you have to write it and, if you aren’t writing it to your users’ computers you have to write it to the database. Hiding beneath all of that fancy database software is something as simple as a pile of disks for storing data in rows and tables. Making sure the disks are working as fast as they can is critical to keeping a database running at peak performance.

A Note About How Gigabit Ethernet Sucks and Infiniband is Your Friend

Gigabit ethernet sucks. If disk I/O is your absolute bottleneck, you only have two options – you need to write to as many drives as possible. We’ll find out why that isn’t entirely possible in EC2. The other option is to make the connection between your database server and the storage as fast as possible. Since you can’t get super fast storage in EC2, you’ll have to find another way to make your database fast.

Just How Fast is Gigabit Ethernet?

The question isn’t rhetorical. It’s important to understand how fast gigabit ethernet is. Gigabit ethernet can really only transfer, at most, 120 megabytes per second. That’s the theoretical maximum assuming that everything along the line is operating perfectly and there is no latency or additional hops to make.

We’re not likely to see this in the real world. You’re not likely to see this in your own server room and you’re sure as hell not going to see it in EC2.

Why is your storage going to be slow? You have keep in mind that not everything involved may be able to push data at 120 MB/s; the drives could be slow, fragment, or you could be sharing space with someone else who is doing a lot of reading and writing. Other people could be reading from the same host as you or they could be streaming movies from the host to a customer in the suburbs.

In an attempt to find an answer, I conducted several tests on an EC2 instance over the course of several days to answer the question, “Just how fast is gigabit ethernet?”

Testing Methodology

For all of the tests, I used the same m2.4xlarge instance. I installed it from a standard Windows Server 2008R2 SP1 AMI that Amazon supply. Nothing was changed with the operating system. This Windows was about as vanilla as it gets.

For my tests with the drives, I used EBS volumes that were allocated in complete 1TB chunks. I made two rounds of tests. In both cases, the drives were formatted with a 64k sector size. The first round of tests was done with drives that were quick formatted. The second round of tests were performed with drives that were not quick formatted. FYI, formatting 10TB of drives in EC2 takes about 2 days. I used a Large Windows instance to format the drives at a cost of about $26 in CPU time plus another $57.20 in I/O cost just to format the drives.

The first set of tests I ran involved using CrystalDiskMark. I used the default configuration and ran it across the quick formatted drives. Drives were configured with 1 EBS volume, 2 EBS volumes, 3 EBS volumes, and 4 EBS volumes. I conducted a second set of CrystalDiskMark tests using fully formatted drives with 1, 2, 3, 4, and 10 EBS volumes in a single drive.

The second set of tests was more complex and involved using SQLIO to simulate sequential and random reads from SQL Server over a period of time. All tests were performed on a single EBS volume, two striped EBS volumes, four striped EBS volumes, and a pair of striped four EBS volumes.

EC2 Storage Test Results

CrystalDiskMark Results - Quick Format

Right away, we can see that performance quickly spikes for sequential reads and writes. While the results for read decrease, this isn’t a reflect of the storage itself so much as it is a reflection of trying to cram a lot of data through a tiny ethernet pipe. Overall, the quick formatted drives don’t show a lot of performance improvement no matter how many spindles we throw at the problem.

CrystalDiskMark Results - Full Format

There are some things that we can conclude about the performance of disks in Amazon’s platform. First and foremost: format your drives. Don’t just use a quick format; use the slow format. The downside is that it takes time to format disks and time is money, especially in the cloud.By using a full format, disk performance improved by 30% for 4K writes with a queue depth of 32 and improved, on the whole, by around 15%. There were a few anomalies – specifically the 4k write performance spike with 4 EBS volumes and the sequential read performance spike for 2 and 4 EBS volumes. The only conclusion I can come to is that reads were cached and did not hit disk.

SQLIO - IOPS

The SQLIO tests show a different story. Right away we can see that sequential I/O performance peaks with a maximum of two volumes, but random reads and writes keep scaling right up until the tests stop – the more spindles that were used, the more random I/O that we could perform. And here’s where things get interesting again. Looking at the graphs you can see that sequential I/O falls apart a little bit north of 1000 IOPS. That’s not a limit of the underlying disks, we’re just maxing out the ethernet connection. When there’s a finite pipe limiting how fast we can read, of course the number of IOPS is going to stop pretty quickly.

SQLIO - MB per second

Looking at the throughput in terms of the amount of data (rather than the number of reads and writes) that we can move through EC2, it’s very easy to see where we hit the ceiling. With a theoretical maximum of 120 MB/s, it’s easy to see that sequential read and write max out when two volumes are use. It’s clear, though, that random reads and writes continue to scale as we add more drives. I suspect that if I had been able to add more spindles, the random write performance would have continued to scale up to 120 MB/s.

What does this mean for SQL Server in EC2?

You can get the random I/O performance that you want, but sequential read/write performance is not going to be good. Taking that a step further, here’s what you don’t want to do in EC2:

  • Data warehousing
  • Large ETL
  • Bulk data processing that requires sequential reads
  • Anything else that requires a lot of sequential read and write

On the flip side, what should you use SQL Server in EC2 for?

  • OLTP
  • Off site processing that isn’t time sensitive
  • Distributed write loads (sharding)

SQL Server hosted in EC2 is going to be very effective for highly random loads and especially for loads where data can be kept in memory (currently less than 68.4 GB).

A Sidebar about Ephemeral Storage

Don’t use it. It goes away and may never come back. Well, it goes away when your instance reboots.

Because it’s the drives that live in your server chassis. You can’t predict where your server is going to be when you turn it back on again, so you can’t predict if that data is going to stay with you or not. This is a best practice for virtualization, if you think about it. When you’re setting things up using VMware or Hyper-V you don’t want to attach long-term storage that’s in the server chassis, it makes your virtualization more brittle. Using local storage, if any thing happens (a motherboard fails, a drive fails, a CPU fan goes out, or memory fails) you’ve lost that host. You can’t bring that VM up on another server because the OS is still on hard drives in that broken server.

Local storage is great for temporary (ephemeral) things. Make sure that you take that into account when you’re designing your infrastructure. Fast, cheap, temporary storage is great for fast, cheap, temporary operations like TempDB or local scratch disks.

First Touch Penalty

Amazon mention in a lot of their documentation that there’s a penalty, and potentially a large one, for the first write to a block of storage. When you look at the numbers below you’ll realize that they weren’t kidding. Amazon further go on to claim that if you benchmark the storage (as I did) you’ll be horrified by the results (as I was) but that you shouldn’t worry because the first write penalty is only really obvious during benchmarking and will be amortized away for time in the real world.

Here’s where I have to call bullshit. If your workload consists almost entirely of writing new data, you’re going to see a first touch penalty until the drive is full. It won’t end. Writes will suck until your drive is full. Then you’ll add more drives and the suck will continue. This is compounded for relational databases where the currently accepted best practice is to ensure sequential writes by clustering on an arbitrarily increasing integer.

The only way to guarantee acceptable performance is to format your drives and write to them block by agonizing block until the storage is full formatted.

Staying Up in the Clouds – HA/DR Options

Clustering: Sad Trombone of the Cloud

You can’t cluster in EC2. Don’t try. There’s no shared storage. EBS volumes can only be attached to a single server at a time. You could share the drives, but you really shouldn’t do that. You could use some Windows based SAN system that mounts drives and pretends it’s a SAN, but without any guarantees of performance or longevity, why would you want to?

We’ll just leave this one as: You can’t cluster in EC2.

Availability zones and regions

In case you didn’t know, Amazon’s magical cloud is divided up into regions. Each region is made up of multiple availability zones. They’re all right next door to each other, but they’re in separate buildings with separate internet access and separate power.

Availability zones exist to protect users from localized failure. Hopefully, if there’s a problem in a data center, it’s only going to be a problem in one data center (one availability zone). If that zone goes down, the others should be up and running. If you want to keep your server up and running through local failures, you need to make sure you keep a copy of your data in multiple availability zones. If you want to keep your business up and running in the event of a regional failure (the smoking crater scenario), you need to keep copies of your data in multiple regions.

Region – national level.

Availability zone – local level.

Got it? Good.

Mirroring SQL Server in EC2

One of the easier ways to keep things up and running in the event of a failure is to use SQL Server’s mirroring. Using synchronous mirroring with a witness is going to put you in a great place in terms of disaster recovery. It’s both possible and advisable to put the primary in one zone, the secondary in another, and the witness in a third zone. We can feasibly survive some pretty heavy duty hardship by configuring SQL Server mirroring in multiple availability zones. The applications talking to SQL Server need to be able to fail over between the mirrors but that should be pretty easy for today’s modern developers to handle, right guys?

SQL Server Replication in EC2

Replication is always an option and is probably a better option when you want some kind of geographic fail over. Instead of diving into contentious issues around designing a replication topology, I’m going to hit on the pros and cons of replication in the cloud.

We’ve already seen that there significant limits to network throughput in EC2. We’re limited to, at most, a gigabit of storage throughput. We’re also limited by our ability to write to disk in 64k chunks – only a little bit more than 1000 IOPS are possible at a 64k write size. These limitations become a problem for transactional replication. In an on premise set up, transaction log performance is frequently a problem when replication is involved. If you think that the performance of the transaction log won’t be an issue in the cloud, think again. The I/O characteristics of Elastic Block Storage guarantee that the performance of the transaction log will become a problem under heavy load.

Replication latency is another concern for DBAs in EC2. Not only do reads and writes occur slower, but that read/write slowness means that transactions will be committed to the subscriber further and further behind the publisher. Of course most applications aren’t writing constantly, but it’s important to consider what might happen if the subscriber isn’t able to commit the load that’s being written throughout the business day – will it be able to catch up after hours? If it can catch up today, will it be able to catch up tomorrow?

Crashes happen in EC2, entire regions have gone offline. Unfortunately, at any kind of scale something is bound to be broken right now. What do you do when that happens? What do you do when that happens to the distribution database? (You are running the distributor on a separate server, right?) What do you do when the distributor goes offline and never comes back up, drives corrupted irreparably?

I don’t have the answers, but that’s something your recovery model must take into account when you’re deploying into the cloud.

SQL Server Backups in the Cloud

You gotta keep that data safe, right? Taking backups and hoping for the best isn’t going to cut it once you’ve moved all of your data up into the cloud. You need a retention and recovery strategy.

EBS Data Protection

Amazon’s Elastic Block Storage (EBS) looks like some kind of SAN drives that you can attach to your server. When you look more closely at the disks themselves, they look like drives attached to some kind of storage device powered by Red Hat Enterprise Linux. I’m overusing the phrase “some kind” because you just don’t know what’s back there.

There are, however, some certainties around EBS. An EBS volume lives within a single availability zone. There are multiple drives involved and multiple block level copies of your data. There could be a failure of a back end drive and you’ll never know about it.

The downside of EBS is that there’s no global availability of your data. There is no SAN replication, no global single back up of your data. If you want that, you’ll need to look into using Amazon S3 to provide greater safety.

Be Safe with S3

Amazon Simple Storage Service is a very simple storage service indeed. It’s a block level data store that refers to big binary chunks of data by name. It’s like a filesystem that exists everywhere. Sort of. The important part of S3 is that your data can be persisted at a very paranoid level over a very long period of time. In their own words S3 is “Designed to provide 99.999999999% durability and 99.99% availability of objects over a given year.”

Why mention S3 at all? It’s not very fast and it’s not very easy to mount S3 storage to Windows. There are two things you can do with S3:

  1. Store SQL Server backups.
  2. Snapshot EBS volumes.

Storing SQL Server backups in S3 should be a no brainer for anyone. S3 storage is cheaper than EBS storage and it’s far more durable. Since S3 is global, it’s also possible to push data up to S3 from one region and pull it down in another. Your servers will live on.

S3 can also be used to store snapshots of EBS volumes. Don’t be fooled by the word “snapshot”. The first time you take a snapshot you will likely make a very bad joke about how this isn’t a snapshot, it’s an oil painting. Don’t do that.

The first EBS snapshot to S3 is going to be slow because there is a block level copy of the entire EBS volume happening in the background. All of your data is zipping off into the internet to be safely stored in a bucket somewhere. The upside is that only the blocks of data that get changed are going to get snapshotted. If you perform frequent snapshots then very little data will need to be sent to S3, snapshots will be faster, and recovery should be a breeze. Keep in mind, of course, that these are not crash safe SAN snapshots, so they shouldn’t be used for live databases. I’m sure you can think of cunning ways to work with this.

A Plan for Safe & Secure SQL Backups in EC2

What’s the safe way to manage backups in EC2? Carefully.

Were it up to me, here’s what you’d do:

  1. Backup your data to an EBS volume.
  2. Mount an S3 drive to your Server.
  3. Copy the data to the S3 drive using xcopy with the /J flag

Of course, if it really were up to me, you’d have mirroring set up with a primary in one availability zone, a secondary in another, and the witness in a third. Oh, and you’d be using synchronous mirroring.

Scaling SQL Server in EC2: Scaling Up

This is, after all, why we’re here, right? You’re not just reading this article because you want to learn about database backup best practices and how many IOPS some magical storage device can perform. You want to know how to give your SQL Server some more zip in EC2. There’s a finite limit to how much you can scale up SQL Server in EC2. That limit is currently 8 cores and 68.4GB of RAM. Those 8 cores currently are Intel Xeon X5550s that clock in at 2.66 GHz, but that might change by the time you’re reading this.

In EC2, there’s a limitation on how much we can scale up. Commodity hardware really does mean commodity hardware in this case. If you can’t scale up, the only thing left is to scale out.

Scaling SQL Server in EC2: Scaling Out

It’s incredibly easy to create more instances of SQL Server in EC2. Within a few clicks, you’re most of the way there. You can automate the process further using Amazon’s developer tools to script out additional configuration, attach local storage, and attach EBS storage. The developer tools make it a breeze to create and deploy your own custom images so you have pre-configured instances up and running. You can even use tools like Puppet or Chef to completely automate adding more servers to your environment.

Summing It Up

So, there you have it – it’s possible to get great performance for certain types of SQL Server operations in EC2. If you’re looking for a cheap way to set up a data warehouse, you should look elsewhere. You might be able to slap something together in EC2 that performs well enough, but there will be a lot of man power involved in making that solution work. If you’re looking for a quick way to scale your application up and out without worrying about buying hardware and making sure it’s being used appropriately, then you’ve come to the right place.

Want to read it later? Download the PDF.

Jeremiah Peschka

Jeremiah Peschka has worked as a database and emerging technology expert at Quest Software where he researched new trends and technologies in the world of data storage. Over the course of his career he’s worked with companies across many industries as a system administrator, developer, and DBA. He’s been involved with all aspects of application development and deployment. He likes cheesecake, coffee, and ice cream.

Website - Twitter - Facebook - More Posts

Spring SSWUG Virtual Conference coming up

Last fall, I spoke at the SSWUG Virtual Conference and had a really good time with it, so I signed up again to do the Spring SSWUG Virtual Conference too.

sswug-virtual-conferenceHere’s how it works: I fly out to Tucson to record my sessions in SSWUG’s sssswanky TV studio ahead of time, and then you can watch all of the sessions in your web browser later.  On the release days, when my videos are scheduled to go out for the first time, I sit in on the sessions in the chat room.  I answer questions you’ve got about the material, clarify things, and the other attendees can also share tips and tricks in the chat.  If you can’t clear your schedule on the release days (April 22/23/24), you can go back and watch the videos later – the only drawback being that I won’t be there to hold your hand while you watch it.  Of course, you can always email me with questions too, or catch me on Twitter.

I’m really excited about my sessions:

Log Shipping to the Cloud

In an ideal world, we’d have a standby SQL Server in a disaster recovery datacenter, but we can’t always afford that luxury. In this session, Brent Ozar will explain how to log ship your databases to Amazon S3, a cloud-based file service, and bring up a standby SQL Server in the event of an emergency. It’s like having your own disaster recovery datacenter, but without the cost – until emergency strikes.

Reaching Compliance with SQL Server 2008

To become a production DBA at a public company, hospital, bank or even just a security-minded firm, you need to understand the basics of regulatory compliance. In this session, you’ll learn how to talk the language and learn what tools are available in each version of SQL Server to make your job easier.

SQL Server Encryption

Regulatory compliance needs are a big pain point for DBAs. How do we make sure our data stays safe? Brent will explain the options available for SQL Server 2005 and 2008, do a Transparent Data Encryption implementation with SQL 2008, and demonstrate its strengths and weaknesses. Attendees will get scripts and sample Policy-Based Management policies.

Plus Great Sessions by Much Smarter Guys

Get a load of these:

  • Using Database Mirroring for High Availability by Eric Johnson
  • Become Your Own Picasso: Writing Better T-SQL by Jason Strate
  • Disk IO Tuning for SQL Server 2005 by Kevin Kline
  • 7 SQL Server Development Practices More Evil Than Cursors by Paul Nielsen
  • Panic! Disaster Strikes by Sarah Barela
  • Visual Studio Team System Database Edition – Managing Database Deployment by Ted Malone
  • Optimizing Backup and Restore Performance by Tom LaRock
  • Auditing Your Users by TJ Belt

And I’m only scratching the surface – check out the full list of SQL Server abstracts.

Register for the SSWUG V-Conference now and use VIP code SPVBOZSP09 for $10 off.  That coupon code can be combined with other discounts, too, like the early bird registration or the alumni registration.

This is a heck of a lot of quality training for less than $100.  I’ve heard from a lot of DBAs whose training budgets have been sliced away, and I gotta tell you that this is probably the best way to spend $100 on training.  The video style is really easy to follow, the speakers are just top notch, and the subject matter is really appropriate for what DBAs have to do in their jobs.  I hope you join me in my sessions!

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

Spring SSWUG Virtual Conference

Ah, spring – that time of year when young men’s thoughts turn to T-SQL.  The next SSWUG V-Conference will be April 22-24th, and I’ll be giving a few sessions:

Log Shipping To The Cloud (300-level)

In an ideal world, we’d have a standby SQL Server in a disaster recovery datacenter, but we can’t always afford that luxury. In this session, I’ll explain how to log ship your database to Amazon S3, a cloud-based file service, and bring up a standby SQL Server in the event of an emergency. It’s like having your own disaster recovery datacenter, but without the cost – until emergency strikes.

Attendees will learn:

  • What Amazon S3 is, and how it works as a log shipping target
  • What Amazon EC2 is, and how you can turn on a new SQL Server in the cloud in a matter of minutes
  • Best practices learned from real-life deployments

Log Shipping Basics (100-level)

The boss wants you to plan for disaster, and wants to know the business will be protected if the production SQL Server goes down. Be armed with answers about log shipping with this presentation, which will cover the basic concepts and how to implement it.

Attendees will learn:

  • Best practices for log shipping setups
  • How to use the secondary server for reporting purposes
  • Risks involved with log shipping, and how to avoid them

Reaching Compliance with SQL Server 2008 (200-level)

To become a production DBA at a public company, hospital, bank or even just a security-minded firm, you need to understand the basics of regulatory compliance. In this session, you’ll learn how to talk the language and learn what tools are available in each version of SQL Server to make your job easier.

SQL Server Encryption (200-level)

Regulatory compliance needs are a big pain point for DBAs. How do we make sure our data stays safe? I’ll will explain the options available for SQL Server 2005 and 2008, do a Transparent Data Encryption implementation with SQL 2008, and demonstrate its strengths and weaknesses. Attendees will get scripts and sample Policy-Based Management policies.

If you sign up to attend, I’d highly recommend watching the live sessions on those days (22nd-24th) instead of watching the recorded sessions.  During the live sessions, some of the speakers actually attend, and you can ask them questions in the chat room.  I’ll definitely be there for all of my live sessions.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

Bad storage performance on Amazon EC2 Windows servers

This week I presented at the SSWUG Virtual Conference on how to benchmark your storage performance with Microsoft’s SQLIO utility.  Last week I talked about running SQL Server in the cloud on Amazon EC2.  Take those two things together, and we’ve got storage benchmarking on Amazon EC2 servers:

  • Maximum write speed: 68 MBs/sec
  • Maximum read speed: 8 MBs/sec

I find this too horrifying to comprehend.  I can’t imagine running a database server using a first-generation USB thumb drive for storage, but that’s essentially what this is.

If anybody out there is using Windows on Amazon EC2, I’d be really curious to hear what your SQL Server performance is like relative to your physical in-house servers.  If you’ve got the time, running SQLIO on your EC2 instances would be even better, but it takes several hours to run through my full battery of SQLIO tests.  Running any storage testing utility against an EC2 hard drive would be interesting.

This was not a one-time result – this was a continuous overnight test against an m1.large instance with nothing installed on it.  Every single read test maxed out at around 8 MBs/sec.  Unbelievable.

I’d love to spend more time digging into this, but I’m signing off the computer tonight to start our move up to Michigan.  (I have a linkpost scheduled for Friday already.)  When I get to Michigan, I’ll try a couple of other storage performance test utilities against EC2 instances to see if I’m missing something obvious, and I certainly hope I am.  I’ve never seen performance this bad on a desktop, let alone a server.

Update from Amazon EC2 Support

There’s a thread about slow Amazon EC2 performance for storage on the Amazon forums.  The official answer from Amazon is yes, it’s that slow but they believe it’s normal for SAN storage.  They’re way off base there – I routinely get faster performance out of my home lab gear – but at least they’re watching the forums.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

Getting Started with Amazon EC2 SQL Server 2005

Sometimes you need an offsite database server in case something goes wrong, but you can’t afford a full-blown disaster recovery datacenter.  Or maybe you’ve got some ideas that you’d like to try out with a big SQL Server 2005 box, but you don’t have the hardware sitting around idle.  Or maybe you’d just like to learn SQL Server 2005 – sure, it’s not the latest and greatest, but it’s still the most popular version out in the wild.  Now you’ve got a way to accomplish this for around $1 per hour.

With Amazon EC2, DBAs can “rent” virtual servers running Windows 2003 and SQL Server 2005.  In this article, I’ll explain the five big steps required to turn on your own SQL Server in Amazon’s datacenters.

Step 1: Understand what “cheap” SQL Server hosting costs.

As of this writing (10/2008), here’s the smallest SQL Server you can get at Amazon EC2, what’s known as a “Standard Large” configuration:

  • 7.5 GB of memory
  • 4 EC2 compute units (2 virtual cores with
  • 850 GB of storage
  • 64-bit Windows 2003
  • SQL Server 2005 Standard
  • $1.10 per hour, or roughly $800 per month

Yes, that’s a lot of money, and no, that does not include your bandwidth.  You’ll also incur some additional fees for bandwidth – probably nowhere near $100/mo, but you can use the Amazon EC2 pricing calculator to estimate your numbers.

Let me put it this way: $9 for this much power for one day is a heck of a deal.  I can do a lot of learning and experimenting for my $9.  Even if I use it as a lab box one day per week, that’s still around $40/mo – not a bad deal, especially if I’m a junior DBA who wants a sandbox to break stuff.  At $800/mo, well, we’re in Jaguar XF territory.

Step 2: Get an Amazon EC2 hosting account.

Sign up for an account at aws.amazon.com.  It’s free to enroll, but you have to link it to a method of payment like your credit card or checking account.  Your server usage will be deducted automatically from your account, so don’t blame me if you turn on a whole virtual datacenter and you can’t pay your rent.

After you’ve got the account set up, enable your account for EC2 (the virtual server hosting part) and S3 (where you can store your hard drives):

Step 3: Get the Elasticfox plugin for Firefox to manage your virtual EC2 SQL Servers.

Elasticfox is a browser-based way to manage your virtual army.  It’s free, it’s open source, and it’s the easiest way to get started with EC2.  There’s a guide on getting started with Elasticfox, but I’ll give you the highlight reel:

  • Download the Elasticfox plugin and install it
  • Launch Firefox and click Tools, Elasticfox.
  • Click the Credentials button and input your Amazon Web Services access key and secret key.  Click OK.
  • Create a key pair (to encrypt your Windows admin login) by clicking the KeyPairs tab and click the button to create a new keypair.  Type in anything for the key name, and save the certificate file.
  • Build a set of firewall rules by clicking the Security Groups tab.  In theory, you could skip this step and leave all your ports open, but come on.  Click the Create Security Group button and create a group named SQL Servers.
  • Click the Grant Permission button to set up a firewall rule.  For testing purposes, you can leave the CIDR (source) IPs at 0.0.0.0/0, which means the entire internet.  For production, you would want to restrict this access to your company’s subnet.  In the Protocol Details, set up each of these:
    • TCP/IP 3389 – remote desktop
    • TCP/IP 1433 – SQL connections (if you want to connect to your cloud-based server using SSMS on your desktop)

Step 4: Start up a virtual EC2 SQL server.

Go back to the AMIs and Instances tab and your Elasticfox screen will look something like the below screenshot (you can click on it to enlarge).  I’ve resized my columns to make it easier to see the instances I want:

Elasticfox AMI List

Elasticfox AMI List

In the screenshot, there’s an edit box at the right side where I typed in “sql” to help filter down the list of instances.  Amazon has a ton of servers available, and you have to pay close attention to get the right one.  Here’s a zoomed screenshot, and the highlighted one is the one I’ll be using:

Readthe filename carefully: the “Anon” means it’s not using the extra-charge Windows Authentication Services, and the “v1.01″ is the latest version available as of this writing (10/2008).  Newer versions mean newer patches of Windows and SQL, so the newer the better.

Right-click on the instance you want and click Launch Instance.  The next screen is full of pitfalls.

The Instance Type must be m1.large or greater.  The default is probably going to be m1.small, but that won’t work.  If you try to launch a SQL Server with m1.small, you’ll get this error:

Amazon EC2 Launch Error

Amazon EC2 Launch Error

The error says:

“EC2 responded with an error for RunInstances
InvalidParameterValue: The requested instance type’s architecture (i386) does not match the architec…”

The virtual image for SQL Server is a 64-bit machine, and you have to launch it with an InstanceType of m1.large or larger.  This catches me all the dang time.

For the KeyPair dropdown, choose the certificate name you generated, and under Security Groups, move SQL Server over into the “Launch In” group.

Click Launch, and if all goes well, your instance will show up in the “Your Instances” list in the bottom of the screen.  It takes a minute for the server to boot, but the Elasticfox screen doesn’t update on its own – you have to push the Refresh button manually to see if the server’s available.

Step 5: Connect to your new virtual EC2 SQL Server.

When the server’s State shows “running”, right-click on it and click Get Administrator Password.  Elasticfox will ask for the key pair certificate file that we created earlier.  I’ve had problems with it not always recognizing the file, so just try again and it’ll probably work.  The administrator password will be saved to your clipboard.  Windows doesn’t always allow pasting into the password field, so you may need to bring up Notepad, paste the password in there, and then look at that Notepad screen while you’re logging in.

Click on the server and click the Connect button in Elasticfox.  Elasticfox starts the Remote Desktop client and directs it to the server’s public DNS name, which is going to be something completely forgettable.  Don’t worry – if you’re planning to use this server for disaster recovery, you can assign it a permanent IP address and a better DNS name, and there’s plenty of instructions for that in the Amazon documentation.

When you start SQL Server Management Studio, you’ll either have to put in (local) for the server name to connect to, or start the SQL Server Browser service.

Before you create databases, go into Windows Explorer and take a look at your hard drive configuration:

800 GB, here I come!

800 GB, here I come!

In this screenshot, I’ve got two local drives, D and E, each with 420 GB.  Cha-ching!

From here, the world is your oyster.  You could set up database mirroring, and use this as a disaster recovery server.  Be aware that SQL 2005′s database mirroring is not compressed, so your bandwidth charges may be higher.  Instead, I’d suggest doing log shipping.  The advantage to using log shipping is that you can compress it with Quest LiteSpeed, plus you don’t necessarily have to be running the SQL Server at all times.  You can copy the files to a cheap non-SQL box at Amazon, and only start up the SQL Server once per day (or per week!) to apply the log files.  (I see a blog post coming on that after PASS when things die down.)

Another great use: testing software.  The whole reason I wrote this article today was that I had to test a new beta of Quest Change Director, and I needed a quick new environment to test it in.

I’ve got an upcoming project where I’m working with a European client on a SharePoint whitepaper, and both of us work for secure public companies with paranoid IT departments.  Neither company wants to give VPN access to the others’ staff, so instead we can just build our lab in Amazon EC2 from scratch and both access it from anywhere on the planet.  Everybody wins.

Just don’t forget to shut the server down when you’re done with it, or else you’ll keep paying by the hour!

Update 10/30Stephen Moore asked about SQL Express, and yes, they do have AMIs prebuilt with SQL Express and they start as low as $.125 per hour.  That’s a steal if you only have small databases.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

Amazon EC2 Windows support now live!

You can now spin up a virtual server in Amazon’s datacenter with Windows running.

Even better, you can spin up a fresh new SQL Server for around $1 per hour.

And of course, this comes on a day when I just told myself I wasn’t going to do anything except work on SQLServerPedia, and on a weekend when I’ve got a ton of stuff planned.  You guys will get a head start on me with this one.  I’ll definitely be all over it next week – I can’t wait to write a video tutorial on how to do database mirroring to Amazon’s datacenter.  Gosh, if only there was somewhere that I could host that training video…

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

Amazon EC2 will offer Windows hosting

A lot of cool things are happening at PDC this year, and Amazon’s already showing their cards: Amazon EC2 will offer Windows hosting.

That means you can turn on a brand new Windows machine – or ten – and pay by the hour according to the capacity you’re using.  Less than a dollar an hour in most cases.

What’s that mean for DBAs?

Let’s say you want to have a disaster recovery option for your SQL Server, but you can’t afford a full-time datacenter.  You can turn on a very low-power server in Amazon EC2, just fast enough to handle your incoming logged work, and keep it ready at all times.  When your primary server dies, you could shut down that Amazon instance, turn on a much higher-powered server, and be able to keep up with your load no matter how bulky it is – but without having to pay for that high-powered server all the time.

Or how about another scenario – log shipping.  Copy your transaction logs to Amazon S3 storage – cloud-based, by-the-gb storage – and whenever your main datacenter craters, you can turn on a new Windows box at Amazon and be running your databases from there.  Is it the best solution?  Of course not – but in a disaster, sometimes any solution is better than being completely down.

But wait, there’s more.  Say you want to do proof-of-concept development & testing, like you want to test what happens if you make a major schema change, or you want to test using SQL Server Analysis Services against your data, but your management won’t give you the money to go buy a new testbed server.  Start up a Windows machine at Amazon EC2, pay $1/hour, and do all the development you want.

That’s it – between this and Microsoft’s stuff, I’m adding a cloud category to the blog.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

Oracle announces cloud computing support

I don’t have much insight to add here, but it’s something my readers are probably into: Oracle now supports running on Amazon EC2.  They’ve got prebuilt EC2 instances that you can just turn on, a cloud management portal, and licensing options.

This is such a cool time to be a database administrator.  I can’t wait for the day where people don’t make bad architecture decisions just because they can’t afford to get a real database (and I don’t just mean Oracle by that, of course) from the get-go.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

The Cloud is Coming After Your Children!

I blogged about why database administrators should use Twitter, and I personally loved that tool.  It helped people build faster personal connections with each other, and it helped you get a picture of what the brilliant people were thinking at any given time.  Take Brian Knight, a SQL Server guru, for example – I love being able to see what he’s working on now, because he does things that shape how the DBA world works.

Unfortunately, Twitter started running into some serious infrastructure and architecture problems.  They built the whole thing on top of a couple of MySQL servers with no real Plan B – no way to scale out, no automated cluster failover, no partitioning, and basically no way to make the database fast enough to withstand the user load.

All of this was frustrating, especially since early Twitter adopters tended to be people who worked in & around information technology.  We do this stuff for a living, and it frustrates us when we depend on a tool that is constantly borked.  I got a few laughs out of Twitter’s scaling issues – not because I thought they were easy to solve, but because I’ve worked with coders who took that same approach.  How many times have we heard, “But it works fine on my desktop with ten users….it’ll be fine when we move it to a real server and we have a hundred thousand users.”

Here’s a couple of links with more information about Twitter’s struggles:

That’s right, fifteen million bucks.  A company with a newly minted $15m in the bank should be able to build in some scalability pretty quickly, right?  Buy some faster servers, build in some redundancy, off we go, right?

Not so fast.

Architecture problems take time – especially downtime – to fix, and the one thing Twitter didn’t have was time.  More users piled onto the service every day, more applications built hooks into Twitter’s open API, and the press started asking questions about this cool new service.

Smelling blood, a lot of other competitors have sprung up around Twitter.  Jaiku, Pownce, Friendfeed and many more sites launched to do similar things.

On July 2nd, a new competitor called Identi.ca launched and gathered a lot of press right away.  I’m not going to go into most of the technical differentiators here, but the bottom line is that Identi.ca picked up over 10,000 new users in its first 3 days.

Let me repeat: Identi.ca picked up over 10,000 new users in its first 3 days.

That’s a big rush, and it requires a lot of hardware.  Hardware is expensive.  Datacenter space is expensive.  These things require a lot of VC funding up front, plus planning time to buy, install and provision.  Nobody wants to pay for users they don’t have yet, especially in this tight economy, so how was Identi.ca able to scale up that fast?

Identi.ca is hosted on Amazon EC2 cloud servers.  Anybody can rent EC2 servers by the hour with no capital required, no down payment.  Simply pick what type of servers you want to spin up, and spin up as many as you want.  Pricing ranges from $.10 per hour for a 1-cpu, 1.7gb ram server to $.80 per hour for an 8-core instance with 7-15gb ram.  As load grows, spin up more servers to handle the load.  If the load doesn’t come, or if it comes and goes, just spin down the extra servers.  They’re not sitting around on your balance sheet draining your company dry.

Cloud computing lets anybody with a good idea, good architecture and good coders scale without investing in hardware ahead of time.  Suddenly, those three guys working in a garage (or a coworking space) are much more dangerous to your established – and funded – internet business.

If I worked for Twitter, I would be terrified that a startup company with no VC funding would be able to steal 10,000 of my users from my precious web application in 3 days.  I would be standing in front of my web servers with my arms outstretched, screaming, “No, don’t take my children!”

I don’t work for Twitter, though, so you can catch me on Identi.ca.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

Amazon’s new virtual computing system

Amazon just announced EC2, their rent-a-datacenter plan. You build a custom virtual machine using their tools, and upload it to them. Then you can turn on that virtual machine anytime you want for a whopping ten cents per hour.

It gets even better – if you have scalability needs, like if your site suddenly becomes hugely popular, then you can turn on more machines. You just get billed ten cents per hour per machine.

There’s other costs for storage and bandwidth, but the bottom line is that the cost for a startup ebusiness just got dirt cheap. Implement your idea in a virtual machine, and you’ll be able to handle obscene growth without forking over huge money right away. You don’t have to have a lot of money tied up in a datacenter, don’t have to hire a huge infrastructure staff, etc.

This makes it even easier for your average geek to build a business without the overhead involved with finding and funding staff. It’s awesome. It’s amazing. And it works on a Mac. Gotta love that.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts