SQL Server AlwaysOn: Active Secondaries Luis Vargas Program Manager Microsoft Corporation DBI312
Understand how AlwaysOn (Availability Groups) Active Secondaries allow leveraging HA/DR hardware Read Workloads Backups
Offloading read workloads Offloading backups
AlwaysOn Active Secondaries allow using hardware for more than HA/DR: Offload work from primary Read workloads Backups
Active Secondaries Offloading Read Workloads
Database Mirroring Transactional Replication Run on primary Impacts workload Run on mirror w/snapshots Data Staleness Additional management No failover of read workloads Run on a subscriber Pros: Large number of subscribers Targeted indexes Cons: Separate solution to configure/manage No failover of read workloads
DB2DB1 SQL Server DB2DB1 Primary Active Secondary Reports Log Synchronization DBs in active secondaries are readable Committed transactions are visible eventually When depends on log synchronization latency
DB2DB1 SQL Server Primary Up to 4 secondaries Sync or async
DB2DB1 SQL Server DB2DB1 Primary Secondary Log Synchronization Reports Primary Secondary Reports Manual Failover
NODon’t allow connections READ_ONLYOnly allow connections specifying READ_ONLY intent ALLAllow all connections ALTER AVAILABILITY GROUP ag_name MODIFY REPLICA ON 'server_instance' WITH ( SECONDARY_ROLE ( ALLOW_CONNECTIONS = { NO | READ_ONLY | ALL } ) )
Clients can connect to readable secondary without changes Set ALLOW_CONNECTIONS = ALL Application Intent New connection string property Specifies workload type: READ_ONLY / READ_WRITE Opens new capabilities Disallow connections Automatically route READ_ONLY connections to an active secondary
Configure Routing URL for each secondary ALTER AVAILABILITY GROUP ag_name MODIFY REPLICA ON 'server_name' WITH ( SECONDARY_ROLE ( READ_ONLY_ROUTING_URL = ‘TCP://system-address:port’ ) )
ALTER AVAILABILITY GROUP ag_name MODIFY REPLICA ON 'server_name' WITH ( PRIMARY_ROLE ( READ_ONLY_ROUTING_LIST = {'server_name' [,..n]} ) )
demo AlwaysOn: Active Secondaries Offloading Read Workloads
Mitigations: Use Resource Governor No workload on auto failover target
DDL Redo can still be blocked by read workload XEvent lock_redo_blocked Contention between Redo and read workload avoided internally Workload executed on Snapshot Isolation Locking hints ignored Redo thread never a deadlock victim
Row versions must be created on the active secondary Stored in TempDB 14 bytes needed for version pointer Primary and secondary must have same physical structure If secondary is configured as active: 14 bytes added to rows on the primary (already if SI/RCSI enabled)
Query optimization relies on statistics Created 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 secondary Store on TempDB sys.stats: is_temporary=‘true’ Use most recent statistics Remove on failover, restart, or DROP STATISTICS
Active Secondaries Offloading Backups
PrimarySecondary Failed Backups Database Mirroring R/W workload Only on primary Impacts primary workload Fails after failover
R/W workload Primary Backups Active Secondary Backups Active Secondary Backups On primary or any secondary No need to configure secondaries as readable
Backup on sync or async secondaries Full Backup (Copy-Only) Log Backup Backup automation No Differential Backup
Full Backup (Copy-Only) and Log Backup on secondary If Differential Backup is needed: Full Backup and Differential Backup on primary Log Backup on secondary
Replica Priority 0 (never) (highest) Role Preference Primary Only Secondary Only Secondary If Possible None
Filter out replicas that are not online don’t meet role preference Select highest-priority replica Replica name as tie-breaker Not enforced by BACKUP Implemented as a system function sys.fn_hadr_backup_is_preferred_replica ('dbname') Used by Maintenance Plan Wizard Log Shipping Wizard
Use Recovery Advisor Store backups centrally
demo AlwaysOn: Active Secondaries Offloading Backups
Active Secondaries make AlwaysOn cost-effective Use hardware for more than HA/DR: Offload work from primary Read workloads Backups
AlwaysOn Resource Center SQL Server 2012 Whitepapers AlwaysOn Team Blog
social.msdn.microsoft.com/Forums/en-gb/sqlhadr/
Required Slide Complete an evaluation on CommNet and enter to win!
Scan the Tag to evaluate this session now on myTechEd Mobile