SQL Server Denali AlwaysOn Rocks

The next version of SQL Server, code name Denali, brings huge improvements when it arrives in 2011. To put these changes into perspective, let’s take a trip down memory road first and look at the history of database mirroring.

SQL Server 2005 first introduced mirroring, although it wasn’t fully supported until a service pack. In many ways, mirroring beat the pants off SQL Server’s traditional high availability and disaster recovery methods. Log shipping, clustering, and replication were known for their difficulties in implementation and management. With a few mouse clicks, database administrators could set up a secondary server (aka mirror) to constantly apply the same transactions that were applied to the production server. In synchronous mode, both servers had to commit every transaction in order for it to commit, giving a whole new level of confidence that no transactions would be lost if the primary server suddenly died. In asynchronous mode, servers separated by hundreds or thousands of miles could be kept in sync with the secondary server being a matter of seconds or minutes behind – better than no standby server at all.

Preparing to Compress the Stream

Preparing to Compress the Stream

SQL Server 2008 improved mirroring by compressing the data stream, thereby lowering the bandwidth requirements between the mirroring partners.

In one of the most underrated features of all time, Microsoft even used mirroring to recover from storage corruption. When the primary server detected a corrupt page on disk, it asked the mirror for its copy of the page, and automatically repaired the damage without any DBA intervention whatsoever. Automatic page repair doesn’t get nearly the press it deserves, just silently working away in the background saving the DBA’s bacon.

Database Mirroring’s Drawbacks

While SQL Server was able to read the mirror’s copy of the data to accomplish page repairs, the rest of us weren’t given the ability to do anything helpful with the data. We couldn’t directly access the database. The best we could do is take a snapshot of that database and query the snapshot, but that snapshot was frozen in time – not terribly useful if we want to shed load from the production server. I wanted the ability to run read-only queries against the mirror for reporting purposes or for queries that could live with data a few minutes old. Some companies implemented a series of snapshots for end user access, but this was cumbersome to manage.

Definitely Not Using High Safety Mode

Definitely Not Using High Safety Mode

Unlike log shipping and replication, mirroring only allowed for two SQL Servers to be involved. We could either use mirroring for high availability inside the same datacenter, OR use it for disaster recovery with two servers in different datacenters, but not both. Due to this limitation, a common HA/DR scenario involved using a cluster for the production server (giving local high availability in the event of a server failure) combined with asynchronous mirroring to a remote site. This worked fairly well.

Fairly.

The next problem: database failovers are database-level events. DBAs can fail over one database from the principal to the secondary server, but can’t coordinate the failover of multiple databases simultaneously. In applications that required more than one database, this made automatic failover a non-option. We couldn’t risk letting SQL Server fail over just one database individually without failing over the rest as a group. Even if we tried to manage this manually, database mirroring sometimes still ran into problems when more than ten databases on the same server were mirrored.

Database mirroring didn’t protect objects outside of the database, such as SQL logins and agent jobs. SQL Server 2008 R2 introduced contained databases (DACs), a packaged set of objects that included everything necessary to support a given database application. I abhor DACs for a multitude of reasons, but if you were able to live with their drawbacks, you could more reliably fail over your entire application from datacenter to datacenter.

Enter AlwaysOn: New High Availability & Disaster Recovery

It’s like mirroring, but we get multiple mirrors for many more databases that we can fail over in groups, and we can shed load by querying the mirrors.

That might just be my favorite sentence that I’ve ever typed about a SQL Server feature.

I am the last guy to ever play Microsoft cheerleader – I routinely bash the bejeezus out of things like the DAC Packs, Access, and Windows Phone 7, so believe me when I say I’m genuinely excited about what’s going on here. I’m going to solve a lot of customer problems with mirroring 2.0, and it might be the one killer feature that drives Denali adoption. This is the part where I raise a big, big glass to the SQL Server product team. While I drink, check out the Denali HADR BooksOnline pages and read my thoughts about the specifics.

First off, we get up to four replicas – the artist formerly known as mirrors.

Denali also brings support for mirroring many more databases. We don’t have an exact number yet – we never really got one for 2005 either – but suffice it to say you can mirror more databases with confidence.

Preparing to Demo Availability Groups

Preparing to Demo Availability Groups

DBAs set up availability groups, each of which can have a number of databases. At failover time, we can fail over the entire availability group, thereby ensuring that multi-database applications are failed over correctly.

Denali’s HADRON improvements change my stance on virtualization replication. For the last year, I preferred virtualization replication over database mirroring because it was easier to implement, manage, and fail over. Virtualization still wins if you want to manage all your application failovers on a single pane of glass – it’s easy to manage failovers for SQL Server, Oracle, application servers, file servers, and so on. However, the secondary servers don’t help to shed any load – they’re only activated in the event of a disaster.

AlwaysOn Isn’t Perfect

I need to be honest here and tell you that Denali threw out the baby with the bathwater. There’s going to be a lot of outcry because some of our favorite things about database mirroring, like extremely easy setup, are gone. Take a deep breath and read through this calmly, because I think if you see the big picture, you’ll think we’ve got a much smarter toddler.

AlwaysOn relies on Windows clustering. I know, I know – clustering has a bad reputation because for nearly a decade, it was a cringe-inducing installation followed by validation headaches. Some of my least favorite DBA memories involve misbehaving cluster support calls with finger-pointing between the hardware vendor, SAN vendor, OS vendor, and application vendor. This is different, though, because clusters no longer require shared storage or identical hardware; we can build a cluster with a Dell server in Miami, an HP server in Houston, and a virtual server in New York City, then mirror between them. Now is the right time for AlwaysOn to depend on clustering, because the teething problems are over and clustering is ready for its close-up. (One caveat: clustering requires Windows Server Enterprise Edition, but Microsoft hasn’t officially announced how licensing will work when Denali comes out.)

When you’ve got a clustering/mirroring combo with multiple partners involved, you want to know who’s keeping up and who’s falling behind. You’ll also want to audit the configurations. There’s an improved Availability Group dashboard in SQL Server Management Studio, but I’d argue that GUIs aren’t the answer here. For once, brace yourself – I would actually recommend PowerShell. I’ve given PowerShell the thumbs-down for years, but now I’m going to learn it. It’ll make HADRON management and auditing easier.

Do not try what you're about to see at home. We're what you call consultants.

Do not try what you're about to see at home. We're what you call consultants.

Summing Up Denali AlwaysOn

There’s a lot of challenges here, but as a consultant, I love this feature. It’s a feature built into the product that gives me new ways to handle scalability, high availability, and disaster recovery. There’s a lot of potential in the box, but the clustering requirements are going to scare off many less-experienced users. Folks like us (and you, dear reader, are in the “us” group) are going to be able to parachute in, implement this without spending much money, and have amazing results.

Over the next few months, I’ll be taking you along with me as I dig more into this feature. I plan to implement it in labs at several of my customers right away, and I’ll keep you posted on what we find. If it’s anywhere near as good as it looks, I’m going to be raising a lot of glasses to Microsoft.

If not, I’ll be pointing Diet Coke bottles at Building 35 until they fix the bugs, because this feature could rock.

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

70 Responses to SQL Server Denali AlwaysOn Rocks
  1. mark
    November 25, 2010 | 10:08 PM

    will filestreams be included in this failover?

    • Brent Ozar
      November 29, 2010 | 5:24 PM

      Mark – yes, from what Microsoft told me during a non-NDA interview during the Summit, filestream will be considered a first-class citizen here (as will the new FileTable) and failover will work.

  2. DBATAG
    December 5, 2010 | 12:42 AM

    Hi Brent,

    I just implemented HADR (Availability Groups) in my test virtual Setup.

    I used the following Infrastructure To implement HADR / High Availability Group

    1) Domain Controller for Authentication
    2) Two Virtual Machines with Windows Server 2008 R2 with Failover Clustering installed on each Node.
    3) Local Instance of SQL Server (Not Clustered Instance) installed on Virtual Machines with Windows Server 2008 R2 (which are mentioned in point 2)

    More Details and Step by Step Guide is posted here

    http://sqlserver-training.com/how-to-implement-hadr-a-high-availability-and-disaster-recovery-solution-in-sql-server-step-by-step-guide-with-screenshots/-

    Suggest me some good scenarios to test this HADR (Availability Groups) now.

    • Brent Ozar
      December 5, 2010 | 7:13 AM

      Hi. You can use the same scenarios you’d use clustering, mirroring, log shipping, and replication at work. Ask your managers why you’re using those technologies today (like what kinds of failures you’re trying to avoid, and what the business needs) and then implement those. If you’re not currently using any of those technologies, pick up a book on any of ‘em. Robert Davis’s book on database mirroring is a good starting point.

  3. [...] If you want a great preview, check out fellow MVP Brent Ozar’s post, SQL Server Denali Rocks! [...]

  4. Multiple Mirrors « Voice of the DBA
    January 10, 2011 | 11:57 AM

    [...] locations. These are now called “replicas” and you get up to 4, according to Brent Ozar (HADRON Rocks). I didn’t see that listed, but I’m sure Brent knows more about this stuff than I [...]

  5. [...] SQL Server Denali: HADRON ROCKS. | Brent Ozar – Too Much Information | Brent Ozar – Too Much…. [...]

  6. Doug
    February 4, 2011 | 1:52 PM

    Really great article! Thanks.

  7. [...] systems with automatic failover on all component levels and could invest in Denali’s ”Always On” features after we upgrade Standard edition to Enterprise.  Not counting the test [...]

  8. [...] I’m even more excited about the prospect of AlwaysOn mirroring in SQL Server Denali for offloading these reports.  I mean, what’s more [...]

  9. donaldc
    May 31, 2011 | 8:54 AM

    I really enjoyed reading this blog entry back in November and it’s still pretty much the best overview of Denali High Availability more than 6 months after publication. Brent, reading through the finer detail of HADR, how much of a limitation do you think it’s going to be that there can be only 1 HADR-enabled instance per cluster node? Together with the limitation of 8 databases per availability group, that looks likely to promote over-complicated architectures. Thank you, donaldc

    • Brent Ozar
      May 31, 2011 | 10:54 AM

      Donald – thanks, glad you liked it.

      I’m not worried about the architecture complexity at this point. I generally try to avoid instance stacking anyway.

  10. Fabricio Lima
    July 31, 2011 | 12:51 PM

    Hi! Thanks for this information.

    Can I migrate Jobs and logins with AlwaysOn?

    That’s is a problem from using mirroring.

    Thank You.

    • Brent Ozar
      July 31, 2011 | 2:01 PM

      Fabricio – you can do that with AlwaysOn Clustering, but not AlwaysOn Availability Groups.

      • Fabricio Lima
        August 1, 2011 | 6:30 PM

        Thanks for your time and sorry for my English.

        What is the mean difference between AlwaysOn Clustering and the SQL Server 2008 Clustering? I need to share a Storage yet?

        I was think that with AlwaysOn I will can create a mirror solution that can migrate jobs and logins, like a mix of Cluster + Mirror.

        • Brent Ozar
          August 1, 2011 | 7:30 PM

          Fabricio – no, that’s not the case. You’ll want to do some more digging into AlwaysOn clustering and Availability Groups.

          • Fabricio Lima
            August 1, 2011 | 8:54 PM

            I will do that. Thanks again.

  11. [...] – Doing a demo of SQL Server 2012′s AlwaysOn Availability Groups.  Showing how you can configure one synchronous replica and a couple of read-only asynchronous [...]

  12. [...] Another new feature is AlwaysOn.  AlwaysOn is an enhancement on the database mirroring technology and merged it with clustering and then used for high availability.  Previous to mirroring, which came out in SQL Server 2005, you only had clustering, log shipping or replication to support your needs of scaling out our processing power and high availability needs.  Previous versions of the mirroring were basically just standby versions that you couldn’t query or use until you switched over to it…that is unless you were using snapshots on top of the mirror.  The snapshots worked, but the whole process of maintaining them over the mirrors were cumbersome, and you could only use them for two SQL servers.  Now with AlwaysON, it is like mirroring but you can use it on many different servers and databases via Availability Groups that you can query against and move over to individually and use for scaling out your performance intensive queries.  You can add in a node for availability, scaling out to many other nodes by having secondary or more that are kept up to date with synchronous updates across great distances.  This is really cool, but in a way it was really needed after they took away the read only log shipping capabilities in 2008.  All in all a great edition and I welcome Microsoft’s initiative to recognize the needs of having synchronous copies of our databases for use.  Brent Ozar has a more thorough review of the technology here [...]

  13. [...] From Brent Ozar: SQL Server Denali AlwaysOn Rocks [...]

  14. Clark
    January 18, 2012 | 1:28 PM

    I was wondering is you could elaborate on how Always on can be used to simply zero downtime for application upgrades.

    • Brent Ozar
      January 18, 2012 | 4:15 PM

      Clark – I don’t think you can do zero downtime app upgrades with AlwaysOn Availability Groups. Some schema changes on big databases can still require locking or downtime.

  15. Nick
    January 19, 2012 | 11:54 AM

    Do the active secondaries require full SQL Server licensing?

    • Brent Ozar
      January 19, 2012 | 11:57 AM

      Nick – yes, sadly, full EE licensing.

  16. Rafael
    January 26, 2012 | 12:05 AM

    Hi Brent,

    Just wondering what network in the cluster does sql server denali is using in synchronizing the database in the availability group? is it using the heartbeat?

    • Brent Ozar
      January 26, 2012 | 6:05 AM

      Rafael – it uses the regular network. Also, you may want to check up on the latest clustering technologies – since Windows 2008 and SQL 2008, you don’t need a separate heartbeat network anymore.

      • Rafael
        January 29, 2012 | 8:39 PM

        Thanks a lot for the reply Brent.

Leave a Reply

Wanting to leave an <em>phasis on your comment?

Notify me of followup comments via e-mail. You can also subscribe without commenting.