top of page

SQL Server Always On Read Only Routing Lists

With the release of SQL Server Always on came the ability to query replica’s and offload read only requests. ( MySQL DBA Training) This enhancement is especially great for reporting type apps by allowing the reports to be generated off the secondary replica’s in the availability group and leave the primary for write and update operations. SQL Server Training.



Configuring this routing is not difficult to do.SQL Server Training. With the latest versions of SSMS there is a GUI interface to help. This interface can be found in the AG properties. ( MySQL DBA Training)

In order to configure the read only routing you must provide a routing URL (tcp://servername:portnumber) for each replica in your availability group.SQL Server Training. Once you specify the routing URL you must provide a list of replicas under the routing list section that the Read Only requests are routed to.( MySQL DBA Training)

SQL Server uses the application connection string parameters (ApplicationIntent=ReadOnly) to route the connection to the read only replica.SQL Server Training.

Below you will find sample t-sql to create the routing URLs and the routing lists.

USE [master] GO ALTER AVAILABILITY GROUP [AG_Name] MODIFY REPLICA ON N’servername1\instance’ WITH (SECONDARY_ROLE(READ_ONLY_ROUTING_URL = N’tcp://servername1:instanceportnumber)) GO ALTER AVAILABILITY GROUP [AG_Name] MODIFY REPLICA ON N’servername1\instance’ WITH (PRIMARY_ROLE(READ_ONLY_ROUTING_LIST = (N’servername2\instancename’))) GO USE [master] GO ALTER AVAILABILITY GROUP [AG_Name] MODIFY REPLICA ON N’servername2\instancename’ WITH (SECONDARY_ROLE(READ_ONLY_ROUTING_URL = N’tcp://servername2:instanceportnumber’)) GO ALTER AVAILABILITY GROUP [AG_Name] MODIFY REPLICA ON N’servername2\instancename’ WITH (PRIMARY_ROLE(READ_ONLY_ROUTING_LIST = (N’servername1\instancename’))) GO

160 views0 comments

Recent Posts

See All
bottom of page