Sei sulla pagina 1di 61

SQL Server

Performance Best Practices

Craig Allen
Microsoft Specialist
Dell EMC Corporation – Dallas, TX
Craig.allen@dell.com
Craig’s background Twitter - @msftDude
Blog - www.msftdude.com
Linkedin – www.linkedin.com/in/craigdallen
6 years at Dell EMC

Microsoft Specialist

5 years at Microsoft

Technology Strategist

15 years in Corporate IT

American Airlines Infrastructure Architect


Citigroup Systems Engineer
NationsBank Systems Engineer

5 years in Integration Partners


3
Agenda
Dell EMC and Microsoft – Better together

SQL Server Performance

Architecture Design

Deployment Best Practices

4
4
Better Together
5
5
Microsoft / Dell EMC Alignment
20+ year formal relationship

Dell EMC is Global Alliance Partner

16 Microsoft Competencies

Dell EMC gear in Redmond Labs

and Microsoft Technology Centers (MTC)

21 times Partner of the Year


6
6
Dell EMC and Microsoft
Joint Development
– Dell EMC engineers located at Microsoft headquarters

Joint Solution Validation


Reference Architectures:

– Dell EMC Proven Solutions


– VSPEX Reference Architectures
– Microsoft FAST Track solutions

Joint Customer Support


Cooperative Support agreement:
– Increased speed to Resolution
– Reduction of labor to Resolution
– Improved quality of Resolution
7
7
Dell EMC Proven Solutions
Reference architectures
What to expect -

• Full-stack testing
Not just interoperability
• Shared deployment risk with EMC
• Decreased deployment/testing
Benefits for IT -
cycles
• Assured performance • Faster time to deploy
• Verified building blocks for • Reduced deployment cost
scalability • Improved quality
8
8
SQL Data Warehouse Fast Track
4.0

9
9
www.microsoft.com/mtc

Envisioning Briefings

Strategy Briefings

Architecture Design

Proof of Concepts

Locations:
Atlanta, Boston, Chicago, Dallas, Detroit, Irvine,
Minneapolis, New York, Philadelphia, Reston,
Silicon Valley

10
10
Everything Microsoft at Dell EMC community

www.dellemc.com/everythingmicrosoft
Whitepapers
Case Studies
Videos
Blogs
Discussions

11
11
Dell EMC End-to-End Capabilities for Microsoft
Dell EMC Consulting Services
Strategize • Advise • Architect • Implement • Upgrade • Manage • Support

Content
Tiered/ Backup,
Virtual Business Management
Unified Recovery, Security
Infrastructure Continuity Information
Storage Archive
Governance

12
12
Free Microsoft training
• Microsoft Virtual Academy
www.microsoftvirtualacademy.com

13
SQL Server Challenges, Trends & Solutions

14
CHALLENGES

Performance Availability & Agility &


& Efficiency Copy Mgmt Automation
• Slow queries • Backup of large • Provisioning is
• Tuning is Manual instances not complex & time
scalable consuming
• Inefficient Storage
Utilization • Disaster Recovery is • Snapshots complex
Complex • Copy Mgmt. is
• Operational challenging
Recovery is Slow

15
QUICK POLL: SQL VERSION

What SQL Server version(s) do you


currently maintain/manage?

- SQL 2005/8/R2
- SQL 2012
- SQL 2014
- SQL 2016
16
QUICK POLL: VIRTUALIZATION

Are you are running/managing


virtualized SQL Server ?

- VMWARE
- Hyper-V
- Physical

17
SQL Server

Best Practices and


Performance Tuning

18
SQL SERVER BEST PRACTICES DOCS

http://bit.ly/EMC_msft_bestpractices http://www.emc.com/collateral/white-papers/h13163-
xtremio-microsoft-sql-server-wp.pdf
19
SQL SERVER ON DELL EMC XTREMIO

http://www.emc.com/collateral/white- https://support.emc.com/docu56210_XtremI http://www.emc.com/collateral/white-


paper/h14583-wp-best-practice-sql-server- O-Host-Configuration- papers/h14980-wp-accelerate-sql-lifecycle-
xtremio.pdf Guide.pdf?language=en_US management.pdf

20
SQL SERVER ON DELL EMC UNITY

https://www.emc.com/collateral/wh
ite-papers/h15142-unity-ms-sql-
wp.pdf

21
VMWARE - SQL BEST PRACTICES

• http://www.vmware.com/content/dam/digitalmarketing/vmware/en/pdf/solutions/sql-server-on-vmware-best-practices-guide.pdf

• https://www.vmware.com/content/dam/digitalmarketing/vmware/en/pdf/products/vsan/vmware-microsoft-sql-on-all-flash-virtual-san-6-2.pdf

22
THREE THINGS SQL SERVER CAN BE DOING:
Waiting for workload • no CPU, no wait states
Doing work • high CPU load

Waiting for resources • low CPU, high wait states

If requests sent to SQL Server take a long


time to return results then they either

.. take a long time executing

.. or they take a long time waiting.


23
HOW SQL SERVER EXECUTES A QUERY

24
SQL BPE (BUFFER POOL EXTENSION)

L2
Buffer pool
Backing
Store

Local SSD or NVMe 25


SQL BPE (BUFFER POOL EXTENSION)
https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/buffer-pool-extension

https://www.emc.com/collateral/white-
papers/h13376-sql-server-2014-perf-vnx-
The buffer pool extension size can be up to 32 times the value of appsync-wp.pdf
max_server_memory.

Recommended ratio between the size of the physical memory


(max_server_memory) and the size of the buffer pool extension of 1:16 or
less. A lower ratio in the range of 1:4 to 1:8 may be optimal.
26
VIEWS OF PERFORMANCE

• SQL Server
• Windows Server (physical or virtual machine)

• Virtualization Host
• Storage Array

27
ANALYZE DISK ACTIVITY: IO STATS
All writes (inserts, updates, deletes) must be written to disk.

Queries always return data from the in-memory cache (the buffer pool) but
the cache may not contain the desired data and has to be read from disk.

SQL Server collects, aggregates and exposes information about every data
and log IO request.

First thing to look at is sys.dm_io_virtual_file_stats


This Dynamic Management View (DMV) exposes the number of writes and
reads on each file for every database in the system, along with the
aggregated read and write IO ‘stall’ times.

28
sys.dm_io_virtual_file_stats
https://technet.microsoft.com/en-us/library/ms190326.aspx

Stall times are the total time tasks had to block waiting for transfer of data to and from disk.
The stalls indicate which IO subsytem (which disk) is busy and may even be saturated.

29
COMMON DISK AND IO RELATED WAIT TYPES
sys.dm_os_wait_stats (Transact-SQL)
https://msdn.microsoft.com/en-us/library/ms179984.aspx

PAGEIOLATCH_*
This is the quintessential IO, data read from disk and write to disk wait type.
A task blocked on these wait type is waiting for data to be transferred between the disk and the
in-memory data cache (the buffer pool).

A system that has high aggregate PAGEIOLATCH_* wait types is very likely memory starved and is
spending much time reading data from the disk into the buffer pool.

WRITELOG
This wait type occurs when a task is issuing a COMMIT and it waits for the t-log to write the
transaction commit log record to disk. High average wait times on this wait type indicate that the
disk is writing the t-log slowly and this slows down every transaction.

IO_COMPLETION
This wait type occurs for tasks that are waiting for something else other thanordinary data IO.
(loading an assembly DLL, reading and writing TEMPDB sort files, some special DBCC data reading
operations).

ASYNC_IO_COMPLETION
This wait type is mostly associated with backup, restore, database and database file operation.
30
WINDOWS SERVER
PERFORMANCE INDICATORS

• Memory related performance counters


– PLE (Page Life expectancy)
• 300 second rule is outdated, look for trends

http://www.sqlskills.com/blogs/paul/page-life-expectancy-isnt-what-you-
think/
– Buffer Cache hit ratio
Higher hit ratio the better

However,
• https://www.simple-talk.com/sql/database-administration/great-sql-
server-debates-buffer-cache-hit-ratio/
31
WINDOWS SERVER
PERFORMANCE INDICATORS

• IO related performance counters

– Page reads/sec
– Log Flushes/sec
– Page writes/sec
– Checkpoint pages/sec
– Log write waits
– Physical Disk Object
• The typical focus is not on throughput, but on queue length, indicating
IO operations that take a long time.

32
DISK IO CHARACTERISTICS

33
Storage best practices

34
Spinning Disks - Read/Write ratios matter
Drive type IOPS per drive
SAS 15K 180
SAS 10K 120
NL-SAS / SATA 7.2K 80

RAID Write penalty


Front end IO Back end IO
RAID 1 / 0 1 2
RAID 5 1 4
RAID 6 1 6

35
NTFS Disk Allocation Unit (DAU)
• Format NTFS with a DAU of
– 64KB

– Default is 4KB
Destructive format to change DAU

C:\fsutil fsinfo ntfsinfo C:


Bytes per Cluster

36
Best Practices

37
Considerations for AutoGrow / AutoShrink

• KB-315512
https://support.microsoft.com/en-us/kb/315512

38
FileGroups

39
Oh…. And TEMPDB
TEMPDB is the “public pool” of SQL Server
• Temporary Objects
• User Objects – triggers, queries, temporary tables, variables, etc
• Internal Objects – sorts, triggers, work tables, XML variables or other
LOB data type variables
• Version stores – Snapshot isolation, After triggers, MARS, Online index
rebuilds
• Other objects that use TEMPDB
• Service Broker, event notification, database mail, index creations, user-
defined functions

40
IOPS (Top 10 Disks)
AUS-DB-012 - H: AUS-DB-012 - F: AUS-DB-012 - G:
1,000
AUS-DB-012 - E: AUS-DB-012 - HarddiskVolume6 AUS-DB-012 - D:
AUS-DB-012 - C: AUS-DB-012 - HarddiskVolume1
Read IOPs

500

0
16:15 21:03 1:51 6:39 11:27 16:15 21:03 1:51 6:39 11:27

AUS-DB-012 - H: AUS-DB-012 - F: AUS-DB-012 - G:


40
AUS-DB-012 - E: AUS-DB-012 - HarddiskVolume6 AUS-DB-012 - D:
AUS-DB-012 - C: AUS-DB-012 - HarddiskVolume1
Write IOPs

20

0
16:15 21:03 1:51 6:39 11:27 16:15 21:03 1:51 6:39 11:27

TempDB
41
TempDB

42
OPTIMIZING TEMPDB

• MSDN has an Optimizing tempdb Performance topic


which contains some practical advice
https://technet.microsoft.com/en-us/library/ms175527(v=sql.105).aspx

• Cindy Gross has compiled a collection of SQL Server


TempDB IO Best Practices.
https://blogs.msdn.microsoft.com/cindygross/2009/11/20/compilation-of-sql-server-tempdb-io-best-practices/

43
TEMPDB HOT??

• Move it
– Put on dedicated LUN with dedicated disks

• Get it off the storage array / SAN fabric


– Good: Put on local SSD storage
– Better: PCIe FLASH card

44
PHYSICAL SQL Instance

Spinning Disk design:


Segregation of IO patterns

Database TLogs Indexes TempDB Temp


Files Logs

NTFS NTFS NTFS NTFS NTFS NTFS

LUN LUN LUN LUN LUN LUN


RAID 5 or 6 RAID 1/0 RAID 5 / 6 RAID 0
VIRTUAL SQL Instance

Database TLogs Indexes TempDB Temp


Files Logs

NTFS NTFS NTFS NTFS NTFS NTFS

vmdk vmdk vmdk vmdk vmdk vmdk


VMFS data store VMFS VMFS VMFS

LUN LUN LUN LUN


STORAGE – PERFORMANCE FACTORS
Application
Disk queue depth
vSCSI adapter Adapter queue depth

VMKernel admittance (
VMKernel Disk.SchedNumReqOutstanding)
Per path queue depth
Adapter queue depth

Storage network (zoning,


multipathing)
FC/iSCSI/NAS

HBA target queues


Array SPs
RAID

47
STORAGE – ZONING

• Balance load across storage


controllers
• Best practices:
– Paths: 8 is optimal, 16 max
– Minimize use of ISLs
– 1:1 initiator to target zoning
– Host HBA IO timeout: >=30s

Dell
• MPIO EMC PowerPath
– Multi-Path IO

48
FURTHER READING

Great detailed article on SQL performance…

How to analyse SQL Server performance


Rusanu Consulting
February 24th, 2014

http://rusanu.com/2014/02/24/how-to-analyse-sql-server-performance/

49
SQL SERVER WITH ALL FLASH ARRAYS

50
STORAGE – RAID
TRADITIONAL STORAGE XTREMIO

• Custom RAID configurations for • Built-in flash optimized XDP


Budget
SQL Server data, log, tempdb for with double disk failure
files support
• Stripe data across as many • Automatic load balance across
disks as possible all SSDs, scale out on-demand
• Separate data, log, tempdb Protection
• Random = Sequential, no need
• Separate OLTP vs. analytics data for separation due to
workloads access patterns

Performance

51
IT’S NOT JUST ABOUT SPEED…

• Cost Efficient – Data Reduction


• Simple to Use and Administrate
• Simple to Grow with linear performance
• Data Protection
• Self Service Copy Data Management
• Replication

52
Dell EMC XtremIO

53
CONSISTENT SCALE-OUT PERFORMANCE
W/ INLINE DATA SERVICES XtremIO
Virtual Copies

All Virtual Copies Get FULL Data Services


Always inline IN-MEMORY
Always-on
METADATA

ACTIVE-ACTIVE

SCALE-OUT
Fully Scalable Always On
Thin
Provisioning
Scale-out to architecture
As many copies as needed
Inline Data
Compression
Inline Data
Full Performance Deduplication
Data Protection
Inline Data
Predictable & consistent Encryption
performance

54
SQL SERVER DATA REDUCTION ON XTREMIO
THIN PROVISIONING, DEDUPLICATION, & COMPRESSION

Thin
• Global thin provisioning provide a maximum benefit
Provisioning

Dedupe • Copies & replicas are 100% space efficient upon creation

Compression • Typical range for SQL Server (1.4:1 to 2:1)

55
LINEAR PERFORMANCE AND DATA REDUCTION

• Performance
– Sub-millisecond latency
– Scale up or out on demand

• Automatic compression

• High availability with AlwaysOn AG


– Rapid seeding of replica with copy
– Space efficient replica

• iCDM copies for fast recovery


– User errors
– Logical data corruption

56
ALWAYS ON AVAILABILITY GROUP

Asynchronous-commit mode
The primary replica commits transactions without waiting for acknowledgement that
an asynchronous-commit secondary replica has hardened the log
Synchronous-commit mode
The primary replica waits for a synchronous-commit secondary replica to
acknowledge that it has finished hardening the log. Sync mode requires nodes to be
local to each other (<5ms).
57
ALWAYSON AVAILABILITY GROUPS

• Traditional Challenges
– Deployment time
• Initial deployment requires lengthy backup / restore
– Storage cost
• Storage cost multiplies with the number of replicas
– Time to re-sync
• Slow re-sync after suspending a secondary replica

• Solutions: XTREMIO ICDM

58
ENCRYPTION

• XtremIO – Enterprise Self-Encrypting Drives


• Set and forget
• Compliance
• Eliminate Drive destruction

• SQL TDE – Impacts array data reduction


• SQL 2016 Always Encrypted – reduces impact

59
• SQL 2012 http://download.microsoft.com/download/7/3/C/73CAD4E0-D0B5-4BE5-AB49-D5B886A5AE00/SQL_Server_2012_Licensing_Reference_Guide.pdf

• SQL 2014 http://download.microsoft.com/download/B/4/E/B4E604D9-9D38-4BBA-A927-56E4C872E41C/SQL_Server_2014_Licensing_Guide.pdf

• SQL 2016 http://download.microsoft.com/download/9/C/6/9C6EB70A-8D52-48F4-9F04-08970411B7A3/SQL_Server_2016_Licensing_Guide_EN_US.pdf

60
© Copyright 2016 EMC Corporation. All rights reserved. 61

Potrebbero piacerti anche