patternsqlMinor
Can SQL Server R Services be enabled on a readable secondary?
Viewed 0 times
canreadableenabledsqlsecondaryservicesserver
Problem
To avoid excess load on the primary SQL Server, I'd like to install and enable R Services on a secondary replica of the primary server. Is this possible?
Also, can I push computations from a remote R client onto the secondary server with R Services enabled?
Does this have any impact on the primary at all?
Also, can I push computations from a remote R client onto the secondary server with R Services enabled?
Does this have any impact on the primary at all?
Solution
Readable Secondary is a feature of Always On Availability Groups and you can easily create one of these in Azure using the template from the gallery.
You have to do a little bit of extra config, to configure the read-only routing, something like this:
Connecting to the readable secondary is then a matter of using the
As far as the push compute goes, this is not yet known. Looking on the Always On Availability Groups: Interoperability R Services is not listed.
I would personally be surprised if these features worked together in that way as R is so new, but it's a good thought. If it turns out it doesn't work, you could make it a feature request. I would also say though, when you connect to an AG listener and request read-only routing, it is only that, a request. As AOAG is a high-availability feature, if the secondary is down, you would connect to the primary. So let's say you only enabled R Services on the secondary, you create a situation where these scripts failed when the secondary was not available.
Unfortunately I can't test this out myself as I've burned all my Azure credits this month answering some question for @BrentO : ) Maybe later in the month.
You have to do a little bit of extra config, to configure the read-only routing, something like this:
-- Configure the READ_ONLY_ROUTING_URL
ALTER AVAILABILITY GROUP [Contoso-ag] MODIFY REPLICA ON N'sqlserver-1'
WITH ( SECONDARY_ROLE( READ_ONLY_ROUTING_URL = N'TCP://sqlserver-1.contoso.com:1433') )
ALTER AVAILABILITY GROUP [Contoso-ag] MODIFY REPLICA ON N'sqlserver-0'
WITH ( SECONDARY_ROLE( READ_ONLY_ROUTING_URL = N'TCP://sqlserver-0.contoso.com:1433') )
-- Configure the READ_ONLY_ROUTING_LIST
ALTER AVAILABILITY GROUP [Contoso-ag] MODIFY REPLICA ON N'sqlserver-1'
WITH (PRIMARY_ROLE(READ_ONLY_ROUTING_LIST=(N'sqlserver-0', N'sqlserver-1')))
ALTER AVAILABILITY GROUP [Contoso-ag] MODIFY REPLICA ON N'sqlserver-0'
WITH (PRIMARY_ROLE(READ_ONLY_ROUTING_LIST=(N'sqlserver-1', N'sqlserver-0')))Connecting to the readable secondary is then a matter of using the
ApplicationIntent=ReadOnly facet in your connection string. I have not tried doing this from R but imagine you could. There's an easy way to verify whether or not you are connected to the secondary using sqlcmd which I used recently here.As far as the push compute goes, this is not yet known. Looking on the Always On Availability Groups: Interoperability R Services is not listed.
I would personally be surprised if these features worked together in that way as R is so new, but it's a good thought. If it turns out it doesn't work, you could make it a feature request. I would also say though, when you connect to an AG listener and request read-only routing, it is only that, a request. As AOAG is a high-availability feature, if the secondary is down, you would connect to the primary. So let's say you only enabled R Services on the secondary, you create a situation where these scripts failed when the secondary was not available.
Unfortunately I can't test this out myself as I've burned all my Azure credits this month answering some question for @BrentO : ) Maybe later in the month.
Code Snippets
-- Configure the READ_ONLY_ROUTING_URL
ALTER AVAILABILITY GROUP [Contoso-ag] MODIFY REPLICA ON N'sqlserver-1'
WITH ( SECONDARY_ROLE( READ_ONLY_ROUTING_URL = N'TCP://sqlserver-1.contoso.com:1433') )
ALTER AVAILABILITY GROUP [Contoso-ag] MODIFY REPLICA ON N'sqlserver-0'
WITH ( SECONDARY_ROLE( READ_ONLY_ROUTING_URL = N'TCP://sqlserver-0.contoso.com:1433') )
-- Configure the READ_ONLY_ROUTING_LIST
ALTER AVAILABILITY GROUP [Contoso-ag] MODIFY REPLICA ON N'sqlserver-1'
WITH (PRIMARY_ROLE(READ_ONLY_ROUTING_LIST=(N'sqlserver-0', N'sqlserver-1')))
ALTER AVAILABILITY GROUP [Contoso-ag] MODIFY REPLICA ON N'sqlserver-0'
WITH (PRIMARY_ROLE(READ_ONLY_ROUTING_LIST=(N'sqlserver-1', N'sqlserver-0')))Context
StackExchange Database Administrators Q#142774, answer score: 2
Revisions (0)
No revisions yet.