%3CLINGO-SUB%20id%3D%22lingo-sub-921114%22%20slang%3D%22en-US%22%3ESQL%20Server%20database%20consolidation%20in%20Azure%20SQL%20Database%20Managed%20Instance%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-921114%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%3CU%3EOverview%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWith%20the%20introduction%20of%20Azure%20SQL%20Database%20Managed%20Instance%20(SQL%20MI)%2C%20as%20presented%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsql-database%2Fsql-database-managed-instance%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%2C%20more%20and%20more%20customers%20using%20SQL%20Server%20on%20premise%20looking%20in%20SQL%20MI%20as%20a%20great%20way%20to%20migrate%20to%20Azure.%20Having%20an%20almost%20100%25%20compatibility%20surface%2C%20security%20and%20isolation%20options%20as%20a%20fully%20managed%20PaaS%20with%20attractive%20licensing%20options%20enables%20many%20customers%20to%20take%20the%20leap%20to%20Azure%20SQL%20with%20high%20confidence.%26nbsp%3B%20As%20SQL%20MI%20also%20offers%20a%20scale%20up%20instance%20up%20to%2080%20cores%2C%20it%20enables%20consolidation%20scenarios%20that%20can%20offer%20great%20ROI%20benefits.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBut%2C%20as%20any%20other%20SQL%20server%20consolidation%20effort%2C%20attention%20is%20required%20into%20planning%20resources%20and%20the%20right%20combination%20of%20workloads%20and%20databases%20to%20ensure%20all%20work%20right%20together.%20You%20will%20find%20several%20suggestions%20below%20coming%20from%20similar%20deployments%20and%20projects%20that%20may%20benefit%20you%20as%20well.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CU%3EFindings%20and%20best%20practices%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EChoosing%20the%20right%20SQL%20MI%20tier.%20Business%20Critical%20tier%20should%20be%20the%20main%20choice%20as%20it%20offers%20the%20best%20latency%20for%20IOs%2C%20local%20readable%20replica%20plus%20the%20option%20to%20scale%20up%20to%2080%20cores%20easily.%3C%2FLI%3E%0A%3CLI%3EConsider%20the%20defined%20SQL%20MI%20resource%20limits%20described%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsql-database%2Fsql-database-managed-instance-resource-limits%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%2C%20especially%20the%20100%20databases%20max%20per%20instance%2C%20unless%20the%20instance%20storage%20size%20limit%20has%20been%20reached.%3C%2FLI%3E%0A%3CLI%3EgeoDR%20considerations%3COL%3E%0A%3CLI%3EEnsure%20you%20group%20databases%20in%20your%20consolidated%20instance%20that%20are%20somehow%20related%20and%20they%20can%20failover%20together%20when%20a%20geoDR%20failover%20is%20triggered%20as%20currently%20geoDR%20is%20done%20at%20a%20SQL%20MI%20instance%20and%20not%20at%20a%20database%20level.%3C%2FLI%3E%0A%3CLI%3EBy%20default%2C%20the%20geoDR%20instances%20use%20the%20same%20number%20of%20cores%20as%20the%20primary%20database.%20This%20is%20to%20ensure%20equal%20capacity%20in%20case%20of%20a%20failover%20plus%20maintain%20low%20latency%20when%20applying%20data%20changes%20from%20the%20primary.%3C%2FLI%3E%0A%3CLI%3ENow%2C%20we%20have%20seen%20customer%20cases%20where%20they%20try%20to%20manage%20overall%20cost%20by%20lowering%20the%20number%20of%20cores%20in%20geoDR%20instance.%20For%20example%2C%20they%20may%20have%2064%20cores%20in%20the%20primary%20db%20and%2032%20cores%20on%20the%20geoDR%20instance%20as%20they%20both%20support%20up%20to%204TB%20storage.%3C%2FLI%3E%0A%3CLI%3EBut%2C%20you%20should%20monitor%20the%20log%20applying%20rate%20to%20ensure%20it%20does%20not%20fall%20far%20behind.%20If%20geoDR%20instances%20lag%20is%20too%20high%2C%20we%20will%20throttle%20the%20primary%20database%20log%20rate%20to%20ensure%20geoDR%20catches%20up%2C%20as%20said%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fupdates%2Fnew-active-geo-replication-optimization-is-coming-to-production-soon%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%20That%20may%20affect%20the%20primary%20DB%20performance.%20If%20that%20happens%20often%2C%20you%20may%20need%20to%20increase%20the%20number%20of%20cores%20in%20geoDR%20instances.%3C%2FLI%3E%0A%3CLI%3EYou%20can%20find%20details%20%3CA%20href%3D%22https%3A%2F%2Fnam06.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fdocs.microsoft.com%252Fen-us%252Fazure%252Fsql-database%252Fsql-database-active-geo-replication%2523monitoring-geo-replication-lag%26amp%3Bdata%3D02%257C01%257Cndritsas%2540microsoft.com%257C1a82152a792d4189412d08d752609d45%257C72f988bf86f141af91ab2d7cd011db47%257C1%257C0%257C637068447227260138%26amp%3Bsdata%3Dcrig3P%252BywidBS%252Bbh1ErPyqOmoxgHcb%252BdDfHe7JyLlcs%253D%26amp%3Breserved%3D0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%20on%20how%20to%20manage%20better%20the%20geoDR%20secondary%20monitoring%20and%20setup.%3C%2FLI%3E%0A%3CLI%3EAn%20additional%20aspect%20to%20consider%20in%20sizing%20the%20geoDR%20instances%20is%20if%20you%20use%20them%20for%20reading%20and%20reporting%20purposes.%20That%20will%20add%20load%20on%20the%20instance%20resources%20and%20it%20should%20be%20considered%20in%20the%20sizing%20planning.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3EPlan%20for%20the%20log%20rate%20throughput%20levels%3COL%3E%0A%3CLI%3EIn%20SQL%20MI%2C%20log%20rate%20(MB%2Fs)%20grows%20up%20to%2048MB%2Fs%2C%20available%20at%2016%20cores%20instances.%20Adding%20more%20cores%20does%20not%20increase%20the%20log%20rate%20beyond%2048MB%2Fs.%3C%2FLI%3E%0A%3CLI%3EIf%20your%20applications%20write%20in%20the%20log%20extensively%20or%20you%20expect%20low%20latency%20in%20the%20log%20writes%2C%20you%20should%20consider%20that%20in%20your%20consolidation%20planning%20as%20the%2048MB%2Fs%20current%20limit%20is%20per%20instance%20plus%20it%20includes%20the%20needs%20for%20the%20tempDB%20log.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3EManage%20the%20MAXDOP%20value.%20As%20you%20migrate%20to%20a%20higher%20core%20instance%20than%20before%2C%20you%20may%20need%20to%20limit%20the%20MAXDOP%20per%20database%2C%20at%20about%208%20or%20less.%20MAXDOP%20can%20be%20set%20at%20instance%20or%20database%20or%20even%20query%20level.%20if%20MAXDOP%20is%200%20at%20the%20database%20level%2C%20it%20inherits%20the%20value%20from%20the%20instance%20level.%20This%20is%20more%20critical%20for%20customers%20running%20traditional%20row%20mode%20parallelism%20in%20queries%20as%20that%20execution%20model%20is%20less%20flexible%20than%20batch%20mode%20parallelism.%20If%20you%20have%20an%20application%20being%20migrated%20to%20MI%2C%20then%20using%20compatibility%20level%20150%20may%20improve%20performance%20because%20it%20allows%20batch%20mode%20to%20run%20over%20b-tree%20index%20storage%20models.%20You%20still%20will%20likely%20want%20a%20MAXDOP%20setting%2C%20but%20this%20is%20another%20option%20to%20consider%20to%20get%20the%20best%20performance%20on%20larger%20systems%20as%20batch%20mode%20scales%20to%20higher%20core%20counts%20vs.%20row%20mode%20parallelism.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3COL%20start%3D%226%22%3E%0A%3CLI%3EWhen%20scaling%20up%20you%20SQL%20MI%20instance%2C%20the%20scaling%20operation%20introduces%20short%20downtime%20at%20the%20end%20of%20the%20operation%2C%20typically%20up%20to%2010%20seconds.%20Duration%20of%20a%20failover%20can%20vary%20significantly%20in%20case%20of%20long-running%20transactions%20that%20happen%20on%20the%20databases%20due%20to%20prolonged%20recovery%20time.%20Hence%2C%20it%E2%80%99s%20not%20recommended%20to%20scale%20compute%20or%20storage%20of%20Azure%20SQL%20Database%20managed%20instance%20or%20to%20change%20service%20tier%20at%20the%20same%20time%20with%20the%20long-running%20transactions%20(data%20import%2C%20data%20processing%20jobs%2C%20index%20rebuild%2C%20etc.).%20Database%20failover%20that%20will%20be%20performed%20at%20the%20end%20of%20the%20operation%20will%20cancel%20ongoing%20transactions%20and%20result%20in%20prolonged%20recovery%20time.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3EAs%20such%2C%20consider%20also%20enabling%20accelerated%20database%20recovery%20in%20SQL%20MI%2C%20as%20discussed%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsql-database%2Fsql-database-accelerated-database-recovery%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3COL%20start%3D%227%22%3E%0A%3CLI%3EConsider%20running%20database%20auto%20statistics%20in%20async%20mode%20to%20minimize%20the%20impact%20and%20potential%20blocking%20with%20other%20long%20running%20processes.%20This%20can%20help%20especially%20if%20your%20SQL%20Server%20frequently%20executes%20the%20same%20query%20or%20similar%20cached%20query%20plans.%3COL%3E%0A%3CLI%3ENote%3A%20to%20use%20AUTO_UPDATE_STATISTICS_ASYNC%2C%20the%20AUTO_UPDATE_STATISTICS%20needs%20to%20be%20enabled%20as%20well.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-921114%22%20slang%3D%22en-US%22%3E%3CP%3EReview%20best%20practices%20and%20suggestions%20as%20you%20consider%20migrating%20and%20consolidating%20SQL%20Server%20databases%20into%20Azure%20SQL%20Database%20Managed%20Instance.%3C%2FP%3E%3C%2FLINGO-TEASER%3E

Overview

With the introduction of Azure SQL Database Managed Instance (SQL MI), as presented here, more and more customers using SQL Server on premise looking in SQL MI as a great way to migrate to Azure. Having an almost 100% compatibility surface, security and isolation options as a fully managed PaaS with attractive licensing options enables many customers to take the leap to Azure SQL with high confidence.  As SQL MI also offers a scale up instance up to 80 cores, it enables consolidation scenarios that can offer great ROI benefits.

 

But, as any other SQL server consolidation effort, attention is required into planning resources and the right combination of workloads and databases to ensure all work right together. You will find several suggestions below coming from similar deployments and projects that may benefit you as well.

 

Findings and best practices

  1. Choosing the right SQL MI tier. Business Critical tier should be the main choice as it offers the best latency for IOs, local readable replica plus the option to scale up to 80 cores easily.
  2. Consider the defined SQL MI resource limits described here, especially the 100 databases max per instance, unless the instance storage size limit has been reached.
  3. geoDR considerations
    1. Ensure you group databases in your consolidated instance that are somehow related and they can failover together when a geoDR failover is triggered as currently geoDR is done at a SQL MI instance and not at a database level.
    2. By default, the geoDR instances use the same number of cores as the primary database. This is to ensure equal capacity in case of a failover plus maintain low latency when applying data changes from the primary.
    3. Now, we have seen customer cases where they try to manage overall cost by lowering the number of cores in geoDR instance. For example, they may have 64 cores in the primary db and 32 cores on the geoDR instance as they both support up to 4TB storage.
    4. But, you should monitor the log applying rate to ensure it does not fall far behind. If geoDR instances lag is too high, we will throttle the primary database log rate to ensure geoDR catches up, as said here. That may affect the primary DB performance. If that happens often, you may need to increase the number of cores in geoDR instances.
    5. You can find details here on how to manage better the geoDR secondary monitoring and setup.
    6. An additional aspect to consider in sizing the geoDR instances is if you use them for reading and reporting purposes. That will add load on the instance resources and it should be considered in the sizing planning.
  4. Plan for the log rate throughput levels
    1. In SQL MI, log rate (MB/s) grows up to 48MB/s, available at 16 cores instances. Adding more cores does not increase the log rate beyond 48MB/s.
    2. If your applications write in the log extensively or you expect low latency in the log writes, you should consider that in your consolidation planning as the 48MB/s current limit is per instance plus it includes the needs for the tempDB log.
  5. Manage the MAXDOP value. As you migrate to a higher core instance than before, you may need to limit the MAXDOP per database, at about 8 or less. MAXDOP can be set at instance or database or even query level. if MAXDOP is 0 at the database level, it inherits the value from the instance level. This is more critical for customers running traditional row mode parallelism in queries as that execution model is less flexible than batch mode parallelism. If you have an application being migrated to MI, then using compatibility level 150 may improve performance because it allows batch mode to run over b-tree index storage models. You still will likely want a MAXDOP setting, but this is another option to consider to get the best performance on larger systems as batch mode scales to higher core counts vs. row mode parallelism.
  1. When scaling up you SQL MI instance, the scaling operation introduces short downtime at the end of the operation, typically up to 10 seconds. Duration of a failover can vary significantly in case of long-running transactions that happen on the databases due to prolonged recovery time. Hence, it’s not recommended to scale compute or storage of Azure SQL Database managed instance or to change service tier at the same time with the long-running transactions (data import, data processing jobs, index rebuild, etc.). Database failover that will be performed at the end of the operation will cancel ongoing transactions and result in prolonged recovery time.

As such, consider also enabling accelerated database recovery in SQL MI, as discussed here.

  1. Consider running database auto statistics in async mode to minimize the impact and potential blocking with other long running processes. This can help especially if your SQL Server frequently executes the same query or similar cached query plans.
    1. Note: to use AUTO_UPDATE_STATISTICS_ASYNC, the AUTO_UPDATE_STATISTICS needs to be enabled as well.