SQL Server AlwaysOn: Active Secondaries Luis Vargas Program Manager Microsoft Corporation DBI312.

Post on 01-Apr-2015

221 views 2 download

Tags:

Transcript of SQL Server AlwaysOn: Active Secondaries Luis Vargas Program Manager Microsoft Corporation DBI312.

SQL Server AlwaysOn: Active Secondaries

Luis VargasProgram ManagerMicrosoft Corporation

DBI312

Understand the capabilities, limitations, and considerations

Understand how AlwaysOn (Availability Groups) Active Secondaries allow leveraging HA/DR hardware

Read WorkloadsBackups

Session Objectives

Agenda

AlwaysOn Active Secondaries

Offloading read workloads

Offloading backups

AlwaysOn Active Secondaries

Cost-effectiveness is criticalIdle hardware represents wasted resourcesDatabase mirror server similar to primaryUtilization is low

AlwaysOn Active Secondaries allow using hardware for more than HA/DR: Offload work from primary

Read workloadsBackups

Active SecondariesOffloading Read Workloads

Running Read Workloads - BeforeDatabase Mirroring Transactional Replication

Run on primary Impacts workload

Run on mirror w/snapshotsData StalenessAdditional managementNo failover of read workloads

Run on a subscriberPros:

Large number of subscribersTargeted indexes

Cons: Separate solution to configure/manageNo failover of read workloads

Running Read Workloads - Now

DB2

DB1

SQL Server SQL Server

DB2

DB1

PrimaryActiveSecondary

ReportsLog Synchronization

DBs in active secondaries are readableCommitted transactions are visible eventually

When depends on log synchronization latency

Running Read Workloads - Now

DB2

DB1

SQL Server Primary

Up to 4 secondariesSync or async

Running Read Workloads - Now

DB2

DB1

SQL Server SQL Server

DB2

DB1

Primary Secondary

Log Synchronization

Reports

PrimarySecondary

Reports

ManualFailover

Read workloads can be automatically routed to an active secondary

ALLOW_CONNECTIONS setting

Configuring Secondary as Readable

NO Don’t allow connections

READ_ONLY Only allow connections specifying READ_ONLY intent

ALL Allow all connections

ALTER AVAILABILITY GROUP ag_nameMODIFY REPLICA ON 'server_instance'WITH (

SECONDARY_ROLE ( ALLOW_CONNECTIONS = { NO | READ_ONLY | ALL } ) )

Clients can connect to readable secondary without changesSet ALLOW_CONNECTIONS = ALL

Clients Connectivity

Application IntentNew connection string propertySpecifies workload type: READ_ONLY / READ_WRITEOpens new capabilities

Disallow connectionsAutomatically route READ_ONLY connections to an active secondary

Configure Routing URL for each secondary

Configuring Routing of Read-Only Connections

ALTER AVAILABILITY GROUP ag_nameMODIFY REPLICA ON 'server_name'WITH (

SECONDARY_ROLE ( READ_ONLY_ROUTING_URL = ‘TCP://system-

address:port’ ) )

Create Routing List at each replica that can be primary

Configuring Routing of Read-Only Connections

ALTER AVAILABILITY GROUP ag_nameMODIFY REPLICA ON 'server_name'WITH (

PRIMARY_ROLE ( READ_ONLY_ROUTING_LIST = {'server_name'

[,..n]} ) )

demo AlwaysOn: Active SecondariesOffloading Read Workloads

Log Synchronization to Secondary

Impact of Read Workload

Workload can take resources from Redo threadRedo can fall behind impact RTO

Mitigations:Use Resource GovernorNo workload on auto failover target

DDL Redo can still be blocked by read workloadXEvent lock_redo_blocked

Contention between Redo and read workload avoided internally

Workload executed on Snapshot IsolationLocking hints ignoredRedo thread never a deadlock victim

Impact of Read Workload

Row versions must be created on the active secondaryStored in TempDB14 bytes needed for version pointer

Snapshot Isolation and Row Versioning

Primary and secondary must have same physical structureIf secondary is configured as active:

14 bytes added to rows on the primary (already if SI/RCSI enabled)

Query Optimization on Active Secondary

Query optimization relies on statisticsCreated by indexes and read workloads

Statistics created on primary are redone on secondary But, read workloads at secondaries are different from primary workloads

So, auto-create statistics on secondaryStore on TempDBsys.stats: is_temporary=‘true’

Use most recent statisticsRemove on failover, restart, or DROP STATISTICS

Active Secondaries

Offloading Backups

Creating Backups - Before

Primary Secondary

Failed

Backups Backups

Database Mirroring

R/W workload

Only on primaryImpacts primary workloadFails after failover

R/W workload

PrimaryBackups

ActiveSecondary

Backups

ActiveSecondary

Backups

Creating Backups - Now

On primary or any secondaryNo need to configure secondaries as readable

Capabilities

Backup on sync or async secondaries

Full Backup (Copy-Only)Log Backup

Backup automation

No Differential Backup

Single Log Backup Chain

Backup Strategy

Full Backup (Copy-Only) and Log Backup on secondary

If Differential Backup is needed:Full Backup and Differential Backup on primaryLog Backup on secondary

Replica Priority0 (never) ... 100 (highest)

Backup Automation

Role PreferencePrimary OnlySecondary OnlySecondary If PossibleNone

Backup Automation

Filter out replicas that are not onlinedon’t meet role preference

Select highest-priority replicaReplica name as tie-breaker

Not enforced by BACKUPImplemented as a system function

sys.fn_hadr_backup_is_preferred_replica ('dbname')

Used byMaintenance Plan Wizard Log Shipping Wizard

Recommendations

Use Recovery Advisor

Store backups centrally

demo

AlwaysOn: Active SecondariesOffloading Backups

Active Secondaries make AlwaysOn cost-effective

Summary

Use hardware for more than HA/DR: Offload work from primary

Read workloadsBackups

Resources

AlwaysOn Resource Center http://msdn.microsoft.com/en-us/sqlserver/gg490638.aspx

SQL Server 2012 Whitepapershttp://msdn.microsoft.com/en-us/library/hh403491

AlwaysOn Team Bloghttp://blogs.msdn.com/b/sqlalwayson/

Contacts

luis.vargas@microsoft.com

social.msdn.microsoft.com/Forums/en-gb/sqlhadr/

Complete an evaluation on CommNet and enter to win!

MS Tag

Scan the Tagto evaluate thissession now onmyTechEd Mobile

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to

be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS

PRESENTATION.