Clustering for Azure SQL Database
Clustering provides high‑availability and load‑balancing for Azure SQL Managed Instances and the premium tier of Azure SQL Database. This guide walks you through the concepts, setup, monitoring, and best practices.
When to Use Clustering
Clustering is ideal for workloads requiring:
- Zero‑downtime maintenance.
- Automatic failover across regions.
- Scalable read‑only replicas.
Creating a Cluster
Use the Azure portal or Azure CLI. Below is a CLI example:
az sql mi create \\
--name MyCluster \\
--resource-group MyRG \\
--location eastus \\
--sku GP_Gen5_8 \\
--subnet /subscriptions/xxxx/resourceGroups/MyRG/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/default
Monitoring Cluster Health
Azure Monitor Metrics
Key metrics include ReplicaLag, FailoverCount, and CPUPercentage. Set alerts for thresholds that impact SLA.
SQL Server DMVs
SELECT replica_id, replica_server_name, role_desc, state_desc
FROM sys.dm_hadr_availability_replica_states
WHERE is_local = 1;
Best Practices
- Deploy clusters in multiple Availability Zones.
- Use read‑scale replicas for reporting workloads.
- Regularly test failover procedures.
Frequently Asked Questions
Can I add more replicas after creation?
Yes. Use az sql mi replica create to add read‑scale replicas on demand.
What is the cost impact?
Each replica incurs compute and storage charges. Review the pricing calculator to estimate total cost.