Baselining SQL Server for Azure

When migrating SQL Server workloads to Azure there is a trade-off between optimizing for performance and optimizing for costs. You need to know how much work your sql servers are performing when evaluating them prior to a migration.

Ideally you will have a tool that will capture key metrics such as your servers wait statistics as well as resource consumption, however not all of us have that luxury, and they can often be hard to aggregate and report from. This post will show how you can capture a lot of these metrics from within sql server negating the need for a monitoring tool and at the same time giving you an easy repository to analyse from.

To start of you need to know what the metrics are you need to capture, these typically include:

As documented here – https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/performance-guidelines-best-practices-collect-baseline?view=azuresql-vm

Perfmon is one way of capturing this, but it is also readily available from within sql server itself.

Perfmon is one way of capturing this, but it is also readily available from within sql server itself.

CPU

For CPU you can use sys.dm_os_ring_buffers DMV and specifically type ‘RING_BUFFER_SCHEDULER_MONITOR’ which contains cpu utilisation captured every 60 seconds to give you the SQL process utilisation.

Memory

Memory performance metrics can be found by querying the sys.dm_os_performance_counters and sys.dm_os_sys_memory DMV’s


Batch Requests/second

Storage

I have taken Tim Radney’s modification of Paul Randal’s IO Script https://www.sqlskills.com/blogs/tim/capturing-throughput-usage-in-sql-server/

It’s important to note here the time interval of 2 minutes. If you are less worried about bursty throughput 5 minutes is a good interval, but you must be aware it can aggregate throughput over 2 minutes to give the appearance of lower throughput. See the example below:

Max of 1150mbps read at the time shown:

At a 10 second granularity..

Pulling it all together you can have a holistic view of your server :

And if you’re worried about overhead, all of the above in a stored proc is pretty lightweight..


Categories:

Tags:


Comments

One response to “Baselining SQL Server for Azure”

  1. Andy Hogg Avatar

    Very handy, thanks Oli 🙂