{"id":4989,"date":"2015-06-18T20:53:19","date_gmt":"2015-06-18T18:53:19","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/"},"modified":"2015-06-18T20:53:19","modified_gmt":"2015-06-18T18:53:19","slug":"sql-server-2016-availability-groups-and-load-balancing-features","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/","title":{"rendered":"SQL Server 2016 : availability groups and load balancing features"},"content":{"rendered":"<p>Let\u2019s continue with this third post about SQL Server AlwaysOn and availability groups.<\/p>\n<p>Others studies are available here:<\/p>\n<ul>\n<li><a href=\"\/sql-server-2016-availability-groups-and-the-new-option-dbfailover-\" target=\"_blank\" rel=\"noopener noreferrer\">New database issue level detection for automatic failover<\/a><\/li>\n<li><a href=\"\/sql-server-2016-native-support-for-json\" target=\"_blank\" rel=\"noopener noreferrer\">Potential features in standard edition<\/a><\/li>\n<li><a href=\"\/sql-server-2016-availability-groups-and-automatic-failover-enhancements\" target=\"_self\" rel=\"noopener noreferrer\">Automatic failover enhancements<\/a><\/li>\n<\/ul>\n<p>This time I\u2019ll talk about read-only secondaries and the new load-balancing support that will be introduced by SQL Server 2016.<\/p>\n<p>First of all, SQL Server 2014 improved the read-only secondary availability by solving the issue related to secondary accessibility when the primary is offline. However, the redirection to a readable secondary was still basic because it concerned only the first secondary replica defined in the configured priority list. So, unless using a third-party tool it was not possible to use very efficiently all of the resources available from secondaries. Fortunately, the next SQL Server version will change the game by introducing native load-balancing capabilities.<\/p>\n<p>In order to be able to use this new feature, you must define:<\/p>\n<ul>\n<li>The list of possible secondary replicas<\/li>\n<li>A read-only route for each concerned replica<\/li>\n<li>A routing list that include read-only replicas and load-balancing rules<\/li>\n<\/ul>\n<p>At this point I admit to expect a GUI for configuring both read-only routes and the routing list rules in a user friendly fashion even if I prefer using T-SQL to be honest. But anyway, let\u2019s try to configure secondary replicas in round-robin fashion as follows:<\/p>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: green\">\/* enable read-only secondary replicas *\/<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">ALTER<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">AVAILABILITY <span style=\"color: blue\">GROUP [2016Grp]<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">MODIFY<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">REPLICA <span style=\"color: blue\">ON<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: red\">N&#8217;SQL161&#8242;<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">WITH<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">(<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">SECONDARY_ROLE <span style=\"color: gray\">(<span style=\"color: blue\">ALLOW_CONNECTIONS <span style=\"color: gray\">= <span style=\"color: blue\">READ_ONLY<span style=\"color: gray\">)<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">);<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">GO<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">ALTER<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">AVAILABILITY <span style=\"color: blue\">GROUP [2016Grp]<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">MODIFY<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">REPLICA <span style=\"color: blue\">ON<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: red\">N&#8217;SQL161&#8242;<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">WITH<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">(<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">SECONDARY_ROLE <span style=\"color: gray\">(READ_ONLY_ROUTING_URL <span style=\"color: gray\">= <span style=\"color: red\">N&#8217;TCP:\/\/SQL161.dbi-services.test:1433&#8242;<span style=\"color: gray\">)<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">);<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">GO<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">ALTER<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">AVAILABILITY <span style=\"color: blue\">GROUP [2016Grp]<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">MODIFY<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">REPLICA <span style=\"color: blue\">ON<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: red\">N&#8217;SQL162&#8242;<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">WITH<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">(<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">SECONDARY_ROLE <span style=\"color: gray\">(<span style=\"color: blue\">ALLOW_CONNECTIONS <span style=\"color: gray\">= <span style=\"color: blue\">READ_ONLY<span style=\"color: gray\">)<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">);<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">GO<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">ALTER<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">AVAILABILITY <span style=\"color: blue\">GROUP [2016Grp]<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">MODIFY<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">REPLICA <span style=\"color: blue\">ON<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: red\">N&#8217;SQL162&#8242;<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">WITH<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">(<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">SECONDARY_ROLE <span style=\"color: gray\">(READ_ONLY_ROUTING_URL <span style=\"color: gray\">= <span style=\"color: red\">N&#8217;TCP:\/\/SQL162.dbi-services.test:1433&#8242;<span style=\"color: gray\">)<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">);<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">GO<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">ALTER<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">AVAILABILITY <span style=\"color: blue\">GROUP [2016Grp]<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">MODIFY<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">REPLICA <span style=\"color: blue\">ON<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: red\">N&#8217;SQL163&#8242;<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">WITH<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">(<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">SECONDARY_ROLE <span style=\"color: gray\">(<span style=\"color: blue\">ALLOW_CONNECTIONS <span style=\"color: gray\">= <span style=\"color: blue\">READ_ONLY<span style=\"color: gray\">)<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">);<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">GO<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">ALTER<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">AVAILABILITY <span style=\"color: blue\">GROUP [2016Grp]<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">MODIFY<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">REPLICA <span style=\"color: blue\">ON<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: red\">N&#8217;SQL163&#8242;<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">WITH<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">(<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">SECONDARY_ROLE <span style=\"color: gray\">(READ_ONLY_ROUTING_URL <span style=\"color: gray\">= <span style=\"color: red\">N&#8217;TCP:\/\/SQL163.dbi-services.test:1433&#8242;<span style=\"color: gray\">)<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">);<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">GO<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: green\">\/* configure replicas priority list *\/<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">ALTER<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">AVAILABILITY <span style=\"color: blue\">GROUP [2016Grp] <\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">MODIFY<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">REPLICA <span style=\"color: blue\">ON<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: red\">N&#8217;SQL161&#8242;<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">WITH<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">(<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">PRIMARY_ROLE <span style=\"color: gray\">(READ_ONLY_ROUTING_LIST<span style=\"color: gray\">=((<span style=\"color: red\">&#8216;SQL162&#8217;<span style=\"color: gray\">,<span style=\"color: red\">&#8216;SQL163&#8217;<span style=\"color: gray\">)))<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">);<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">ALTER<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">AVAILABILITY <span style=\"color: blue\">GROUP [2016Grp] <\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">MODIFY<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">REPLICA <span style=\"color: blue\">ON<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: red\">N&#8217;SQL162&#8242;<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">WITH<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">(<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">PRIMARY_ROLE <span style=\"color: gray\">(READ_ONLY_ROUTING_LIST<span style=\"color: gray\">=((<span style=\"color: red\">&#8216;SQL161&#8217;<span style=\"color: gray\">,<span style=\"color: red\">&#8216;SQL163&#8217;<span style=\"color: gray\">)))<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">);<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">GO<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">ALTER<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">AVAILABILITY <span style=\"color: blue\">GROUP [2016Grp] <\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">MODIFY<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">REPLICA <span style=\"color: blue\">ON<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: red\">N&#8217;SQL163&#8242;<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">WITH<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">(<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">PRIMARY_ROLE <span style=\"color: gray\">(READ_ONLY_ROUTING_LIST<span style=\"color: gray\">=((<span style=\"color: red\">&#8216;SQL162&#8217;<span style=\"color: gray\">,<span style=\"color: red\">&#8216;SQL161&#8217;<span style=\"color: gray\">)))<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">);<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">GO<\/span><\/div>\n<p>My test lab includes 3 replicas (SQL161, SQL162 and SQL163). The secondaries will be used as read-only replicas with the new load-balancing feature.<\/p>\n<p>Note the double brackets around the replicas list that defines the load-balancing mechanism for the concerned replicas. In my context, I have only two read-only replicas but rules are defined as follows:<\/p>\n<ul>\n<li>(replica1, replica2, replica3): no load-balancing capabilities in this case. The first replica will be used, then the second and finally the third.<\/li>\n<li>((replica1, replica2), replica3): replica1 and replica will be used in a round-robin fashion. The replica3 will be used only if both replica1 and replica2 are not available.<\/li>\n<\/ul>\n<p>Now let\u2019s play with this new infrastructure by using sqlcmd command as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_1-_sqlcmd_readonly.jpg\" alt=\"blog_52_-_1-_sqlcmd_readonly\" width=\"623\" height=\"27\" \/><\/p>\n<p>As reminder, you have to meet some others requirements in order to use correctly the transparent redirection to a secondary replica as using TCP protocol, referencing directly the availability group listener and the concerned database as well and setting the application intent attribute as readonly. So in my case, I reference directly the <em>LST-2016<\/em> listener and the killerdb. I use also the <em>\u2013K<\/em> parameter with <em>READONLY<\/em> attribute. Finally, I run the query SELECT @@SERVERNAME in order to know which replica I am after login.<\/p>\n<p>I ran this command several times and I can state that the load-balancing feature plays its full role.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_2-_sqlcmd_tests.jpg\" alt=\"blog_52_-_2-_sqlcmd_tests\" width=\"631\" height=\"489\" \/><\/p>\n<p>However, let\u2019s play now with the following PowerShell script:<\/p>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console';color: blue\">Clear-Host<span style=\"font-size: 9pt;font-family: 'Lucida Console'\">;<\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console';color: orangered\">$dataSource<span style=\"font-size: 9pt;font-family: 'Lucida Console'\"> <span style=\"color: darkgray\">= <span style=\"color: darkred\">\u201cLST-2016&#8243;;<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console';color: orangered\">$database<span style=\"font-size: 9pt;font-family: 'Lucida Console'\"> <span style=\"color: darkgray\">= <span style=\"color: darkred\">&#8220;killerdb&#8221;;<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console';color: orangered\">$connectionString<span style=\"font-size: 9pt;font-family: 'Lucida Console'\"> <span style=\"color: darkgray\">= <span style=\"color: darkred\">&#8220;Server=tcp:<span style=\"color: orangered\">$dataSource<span style=\"color: darkred\">;Integrated Security=SSPI;Database=<span style=\"color: orangered\">$database<span style=\"color: darkred\">;ApplicationIntent=ReadOnly\u201d;<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 <\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console';color: orangered\">$i<span style=\"font-size: 9pt;font-family: 'Lucida Console'\"> <span style=\"color: darkgray\">= <span style=\"color: purple\">0;<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console';color: darkblue\">while<span style=\"font-size: 9pt;font-family: 'Lucida Console'\"> (<span style=\"color: orangered\">$i <span style=\"color: darkgray\">-le <span style=\"color: purple\">3)<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">{<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 <span style=\"color: blue\">Write-Host <span style=\"color: darkred\">&#8220;Test connexion initial server nb : <span style=\"color: orangered\">$i<span style=\"color: darkred\"> &#8211; <span style=\"color: orangered\">$dataSource<span style=\"color: darkred\"> &#8221; <span style=\"color: navy\">-NoNewline;<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 <span style=\"color: blue\">Write-Host <span style=\"color: darkred\">&#8220;&#8221;;<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 <span style=\"color: blue\">Write-Host <span style=\"color: darkred\">&#8220;&#8221;;<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 <span style=\"color: darkblue\">Try<\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 {<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: orangered\">$connection <span style=\"color: darkgray\">= <span style=\"color: blue\">New-Object <span style=\"color: blueviolet\">System.Data.SqlClient.SqlConnection;<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: orangered\">$connection<span style=\"color: darkgray\">.ConnectionString <span style=\"color: darkgray\">= <span style=\"color: orangered\">$connectionString;<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: orangered\">$connection<span style=\"color: darkgray\">.Open();<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: orangered\">$sqlCommandText<span style=\"color: darkgray\">=<span style=\"color: darkred\">&#8220;SELECT &#8216;Current server : &#8216; + @@SERVERNAME as server_name&#8221;;<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: orangered\">$sqlCommand <span style=\"color: darkgray\">= <span style=\"color: blue\">New-Object <span style=\"color: blueviolet\">system.Data.sqlclient.SqlCommand(<span style=\"color: orangered\">$sqlCommandText<span style=\"color: darkgray\">,<span style=\"color: orangered\">$connection);<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: orangered\">$sqlCommand<span style=\"color: darkgray\">.ExecuteScalar();<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: orangered\">$connection<span style=\"color: darkgray\">.Close();<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: orangered\">$sqlCommand<span style=\"color: darkgray\">.Dispose();<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: orangered\">$connection<span style=\"color: darkgray\">.Dispose();<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 }<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 <span style=\"color: darkblue\">Catch <span style=\"color: darkgray\">[<span style=\"color: teal\">Exception<span style=\"color: darkgray\">]<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 {<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">Write-Host <span style=\"color: darkred\">&#8220;KO&#8221; <span style=\"color: navy\">-ForegroundColor <span style=\"color: blueviolet\">Red;<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">Write-Host <span style=\"color: orangered\">$_<span style=\"color: darkgray\">.Exception<span style=\"color: darkgray\">.Message;<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 }<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 <span style=\"color: blue\">Write-Host <span style=\"color: darkred\">&#8220;&#8221;;<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 <span style=\"color: blue\">Start-Sleep <span style=\"color: purple\">3;<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">\u00a0\u00a0 <span style=\"color: orangered\">$i<span style=\"color: darkgray\">++;<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: #d9d9d9 none repeat scroll 0% 0%\"><span style=\"font-size: 9pt;font-family: 'Lucida Console'\">}<\/span><\/div>\n<p>The result is not the same. The redirection to a read-only replica works perfectly but there was not load-balancing mechanism in action this time as shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_3-_powershell_tests.jpg\" alt=\"blog_52_-_3-_powershell_tests\" width=\"425\" height=\"184\" \/><\/p>\n<p style=\"margin-bottom: 7.5pt;vertical-align: top\"><span style=\"font-size: 11pt;line-height: 107%;font-family: 'Calibri',sans-serif\">What\u2019s going on in the case? In fact and to be honest, I didn\u2019t remember that PowerShell uses connection pooling by default (thanks to Brent Ozar &#8211;<\/span> <a href=\"https:\/\/twitter.com\/BrentO\" target=\"_blank\" rel=\"noopener noreferrer\">@BrentO<\/a> to put me on the right track).<\/p>\n<p style=\"margin-bottom: 7.5pt;vertical-align: top\">Let\u2019s take a look at the output of an extended event session that includes the following events:<\/p>\n<ul>\n<li>sqlserver.login<\/li>\n<li>sqlserver.logout<\/li>\n<li>sqlserver.read_only_route_complete<\/li>\n<li>sqlserver.rpc_completed<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_4-_xe_sqlcmd.jpg\" alt=\"blog_52_-_4-_xe_sqlcmd\" width=\"629\" height=\"92\" \/><\/p>\n<p style=\"margin-bottom: 7.5pt;vertical-align: top\">You can notice that sqlcmd tool doesn\u2019t use connection pooling (is_cached column = false). In this case for each run, SQL Server will calculate the read-only route.<\/p>\n<p style=\"margin-bottom: 7.5pt;vertical-align: top\">However for my PowerShell script the story is not the same as shown below:<\/p>\n<p style=\"margin-bottom: 7.5pt;vertical-align: top\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_5-_xe_pw.jpg\" alt=\"blog_52_-_5-_xe_pw\" width=\"629\" height=\"134\" \/><\/p>\n<p style=\"margin-bottom: 7.5pt;vertical-align: top\">The first connection is not pooled and we can noticed only one read-only route calculation from SQL Server. All of the next connections are pooled and technically they are still alive on the SQL Server instance. This is why the load balancing mechanism is not performed in this case. So this is an important point to keep in mind if you want to plan to benefit to this new feature.<\/p>\n<p><span style=\"font-size: 11pt;line-height: 107%;font-family: 'Calibri',sans-serif\">I also had a dream: Having a real load-balancing feature based on resource scheduling algorithm\u2026 maybe the next step? <\/span>\ud83d\ude42<\/p>\n<p style=\"margin-bottom: 7.5pt;vertical-align: top\">See you<\/p>\n<p>By David Barbarin<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s continue with this third post about SQL Server AlwaysOn and availability groups. Others studies are available here: New database issue level detection for automatic failover Potential features in standard edition Automatic failover enhancements This time I\u2019ll talk about read-only secondaries and the new load-balancing support that will be introduced by SQL Server 2016. First [&hellip;]<\/p>\n","protected":false},"author":26,"featured_media":4990,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[199],"tags":[297,38,84,591,566],"type_dbi":[],"class_list":["post-4989","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hardware-storage","tag-availability-groups","tag-cluster","tag-high-availability","tag-read-only","tag-sql-server-2016"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>SQL Server 2016 : availability groups and load balancing features - dbi Blog<\/title>\n<meta name=\"description\" content=\"SQL Server 2016 : availability groups and load balancing features\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server 2016 : availability groups and load balancing features\" \/>\n<meta property=\"og:description\" content=\"SQL Server 2016 : availability groups and load balancing features\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-18T18:53:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_1-_sqlcmd_readonly.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"963\" \/>\n\t<meta property=\"og:image:height\" content=\"43\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Microsoft Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Microsoft Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/\"},\"author\":{\"name\":\"Microsoft Team\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bfab48333280d616e1170e7369df90a4\"},\"headline\":\"SQL Server 2016 : availability groups and load balancing features\",\"datePublished\":\"2015-06-18T18:53:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/\"},\"wordCount\":949,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/blog_52_-_1-_sqlcmd_readonly.jpg\",\"keywords\":[\"Availability groups\",\"Cluster\",\"High availability\",\"read-only\",\"SQL Server 2016\"],\"articleSection\":[\"Hardware &amp; Storage\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/\",\"name\":\"SQL Server 2016 : availability groups and load balancing features - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/blog_52_-_1-_sqlcmd_readonly.jpg\",\"datePublished\":\"2015-06-18T18:53:19+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bfab48333280d616e1170e7369df90a4\"},\"description\":\"SQL Server 2016 : availability groups and load balancing features\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/blog_52_-_1-_sqlcmd_readonly.jpg\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/blog_52_-_1-_sqlcmd_readonly.jpg\",\"width\":963,\"height\":43},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2016-availability-groups-and-load-balancing-features\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server 2016 : availability groups and load balancing features\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bfab48333280d616e1170e7369df90a4\",\"name\":\"Microsoft Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"caption\":\"Microsoft Team\"},\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/microsoft-team\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"SQL Server 2016 : availability groups and load balancing features - dbi Blog","description":"SQL Server 2016 : availability groups and load balancing features","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server 2016 : availability groups and load balancing features","og_description":"SQL Server 2016 : availability groups and load balancing features","og_url":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/","og_site_name":"dbi Blog","article_published_time":"2015-06-18T18:53:19+00:00","og_image":[{"width":963,"height":43,"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_1-_sqlcmd_readonly.jpg","type":"image\/jpeg"}],"author":"Microsoft Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Microsoft Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/"},"author":{"name":"Microsoft Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4"},"headline":"SQL Server 2016 : availability groups and load balancing features","datePublished":"2015-06-18T18:53:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/"},"wordCount":949,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_1-_sqlcmd_readonly.jpg","keywords":["Availability groups","Cluster","High availability","read-only","SQL Server 2016"],"articleSection":["Hardware &amp; Storage"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/","url":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/","name":"SQL Server 2016 : availability groups and load balancing features - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_1-_sqlcmd_readonly.jpg","datePublished":"2015-06-18T18:53:19+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4"},"description":"SQL Server 2016 : availability groups and load balancing features","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_1-_sqlcmd_readonly.jpg","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_52_-_1-_sqlcmd_readonly.jpg","width":963,"height":43},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2016-availability-groups-and-load-balancing-features\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"SQL Server 2016 : availability groups and load balancing features"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4","name":"Microsoft Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","caption":"Microsoft Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/microsoft-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/4989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=4989"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/4989\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/4990"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=4989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=4989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=4989"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=4989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}