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.
| Component | Role | Practical note |
|---|---|---|
| Primary replica | Accepts read-write workload | Only one primary exists per group |
| Secondary replica | Receives and redoes the log | Up to eight in recent editions |
| Availability group listener | Stable endpoint for clients | Redirects connections after failover |
| Database mirroring endpoint | TCP channel for log transport | Usually port 5022, often encrypted |
| Cluster quorum | Decides which nodes may own the group | Prevents split-brain ownership |
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.
| Mode | Commit acknowledgment | Data loss risk | Typical placement |
|---|---|---|---|
| Synchronous commit | After the secondary hardens the log | None for synchronized replicas | Same data center or low-latency zone |
| Asynchronous commit | Immediately on the primary | Seconds of recent transactions | Remote disaster recovery site |
| Configuration only | Stores cluster metadata only | Not applicable | Third node for quorum in some setups |
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.
Variants and related replication options
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.
| Technology | Scope | Readable secondaries | Key difference |
|---|---|---|---|
| Always On availability groups | Group of databases | Yes | Full feature set in Enterprise edition |
| Basic availability groups | One database, two replicas | No | Standard edition replacement for mirroring |
| Distributed availability groups | Two separate groups | Yes | Spans clusters or regions |
| Contained availability groups | Databases plus logins and jobs | Yes | Replicates instance-level objects |
| Failover cluster instances | Entire SQL Server instance | No | Shared storage, single data copy |
| Database mirroring | One database | No | Deprecated predecessor |
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.
| Symptom | Likely cause | Remedy |
|---|---|---|
| High commit latency | Slow link to a synchronous secondary | Move replica closer or switch to asynchronous |
| Stale reads on secondaries | Redo queue behind the primary | Tune redo, reduce load, monitor latency |
| Group goes offline unexpectedly | Lost cluster quorum | Add a witness and review vote weights |
| Transaction log keeps growing | Secondary disconnected or lagging | Restore connectivity or remove the replica |
| Logins fail after failover | Logins missing or SIDs mismatched | Script logins with matching SIDs |
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.