Always On availability groups

Also known as: AlwaysOn

On this page 7

Always On availability groups are the Microsoft SQL Server feature for high availability and disaster recovery that replicates a defined set of user databases from one primary replica to as many as eight secondary replicas, with automatic or manual failover between them. In database replication, they are the principal way SQL Server keeps databases online through server, storage or site failures.

An availability group fails over as a single unit, so related databases move together. Secondaries can also serve read-only queries and backups, which makes the feature a combined answer to availability, scale-out of reads and geographic redundancy in databases.

How availability groups replicate data

Availability groups replicate at the level of the transaction log. The primary replica sends log blocks to each secondary, where they are hardened to disk and then replayed by a redo thread. This physical log shipping keeps each secondary an exact page-level copy of the primary database.

Coordination relies on Windows Server Failover Clustering (WSFC) or, on Linux, Pacemaker. The cluster tracks node health and quorum, while SQL Server manages the replication itself. Clients connect through an availability group listener, a virtual network name that always points to the current primary.

ComponentRolePractical note
Primary replicaAccepts read-write workloadOnly one primary exists per group
Secondary replicaReceives and redoes the logUp to eight in recent editions
Availability group listenerStable endpoint for clientsRedirects connections after failover
Database mirroring endpointTCP channel for log transportUsually port 5022, often encrypted
Cluster quorumDecides which nodes may own the groupPrevents split-brain ownership
Building blocks of an availability group

Each database in the group reports a synchronization state, such as synchronized, synchronizing or not synchronizing. Only a secondary in the synchronized state is a valid target for failover without data loss, which makes this state the first value administrators check during an incident.

Availability modes and failover types

Each replica is configured with an availability mode that defines when the primary considers a transaction committed. The choice determines the recovery point objective, meaning how much data could be lost during a failover.

ModeCommit acknowledgmentData loss riskTypical placement
Synchronous commitAfter the secondary hardens the logNone for synchronized replicasSame data center or low-latency zone
Asynchronous commitImmediately on the primarySeconds of recent transactionsRemote disaster recovery site
Configuration onlyStores cluster metadata onlyNot applicableThird node for quorum in some setups
Availability modes compared

Failover behavior depends on the mode. Automatic failover requires synchronous commit and a healthy synchronized secondary. Planned manual failover also requires synchronization and loses no data. Forced failover is the last resort for asynchronous replicas and can discard transactions that had not yet reached the secondary.

Microsoft offers several flavors of the feature, and the term is often confused with older high-availability technologies. The table below places availability groups among related replication options.

TechnologyScopeReadable secondariesKey difference
Always On availability groupsGroup of databasesYesFull feature set in Enterprise edition
Basic availability groupsOne database, two replicasNoStandard edition replacement for mirroring
Distributed availability groupsTwo separate groupsYesSpans clusters or regions
Contained availability groupsDatabases plus logins and jobsYesReplicates instance-level objects
Failover cluster instancesEntire SQL Server instanceNoShared storage, single data copy
Database mirroringOne databaseNoDeprecated predecessor
Availability groups and neighboring technologies

Compared with Oracle Data Guard or PostgreSQL streaming replication, availability groups share the idea of physical log-based replication, but add an integrated listener and multi-database failover. Unlike multi-primary systems, only one replica accepts writes at any time.

Designing and operating an availability group

A sound design starts with the recovery time and recovery point objectives for each workload. Two synchronous replicas in one region plus an asynchronous replica in another region is a common pattern that offers automatic local failover and protection against regional outages.

  • Place synchronous replicas close together, since every commit waits for the network round trip and remote disk write.
  • Configure read-only routing so that connections with ApplicationIntent=ReadOnly reach secondaries automatically.
  • Set MultiSubnetFailover=True in connection strings when the listener spans subnets to shorten reconnection.
  • Synchronize logins, jobs and linked servers separately unless contained availability groups are used.
  • Monitor log send and redo queues, which reveal whether secondaries are keeping up.
  • Test failover regularly, including client reconnection behavior, not only database state.

Backups can be offloaded to secondaries using the backup preference setting, although full backups on a secondary must be copy-only. Log backups taken on any replica form a single valid log chain for the group.

Limitations and common failure scenarios

Availability groups protect databases, not everything around them. Problems usually arise from network latency, quorum design and growing queues rather than from the replication engine itself.

SymptomLikely causeRemedy
High commit latencySlow link to a synchronous secondaryMove replica closer or switch to asynchronous
Stale reads on secondariesRedo queue behind the primaryTune redo, reduce load, monitor latency
Group goes offline unexpectedlyLost cluster quorumAdd a witness and review vote weights
Transaction log keeps growingSecondary disconnected or laggingRestore connectivity or remove the replica
Logins fail after failoverLogins missing or SIDs mismatchedScript logins with matching SIDs
Typical problems and remedies

Licensing is another constraint: the full feature requires Enterprise edition, and readable secondaries generally need their own licenses. Readable replicas also add row versioning overhead on the primary, because snapshot reads on secondaries depend on version information.

A non-technical view

Always On availability groups work like keeping live copies of an important ledger in several offices. Every entry written in the main office is copied to the others almost immediately.

If the main office suddenly closes, one of the other offices takes over the ledger and customers keep working, often after only a short pause. Nearby copies stay perfectly up to date, while a distant copy may miss the last few entries but survives a regional disaster.

A concrete example

An online retailer runs its order and inventory databases on SQL Server in one availability group with three replicas: two in its main data center using synchronous commit and automatic failover, and one in a second region using asynchronous commit. Reporting dashboards connect to the local secondary through read-only routing.

During a holiday sale, a storage controller on the primary server failed. The cluster detected the problem and the synchronous secondary became primary within about 20 seconds. Applications reconnected through the listener, and no committed orders were lost.

Because the order and inventory databases belonged to the same group, they failed over together and stayed consistent with each other. The team later rebuilt the failed node, re-added it as a secondary and moved the primary back during a planned maintenance window without downtime for customers.