48

Make your SharePoint fly by tuning and optimizing SQL Server

Embed Size (px)

Citation preview

Page 1: Make your SharePoint  fly by tuning and optimizing SQL Server
Page 2: Make your SharePoint  fly by tuning and optimizing SQL Server

Make your SharePoint Flyby Tuning & Optimizing SQL Server

Serge Luca, Isabelle Van Campenhoudt

ShareQL, Belgium

Add Speaker

Photo here

Page 3: Make your SharePoint  fly by tuning and optimizing SQL Server

Serge Luca

Serge Luca

11 x SharePoint MVP, Brussels

Consultant, speaker, trainer

Managing partner of www.ShareQL.com

SharePoint since 2001

Blog: http://sergeluca.wordpress.com/

[email protected]

@SergeLuca

Serge Luca

Page 4: Make your SharePoint  fly by tuning and optimizing SQL Server

Isabelle Van Campenhoudt

Isabelle Van

Campenhoud

t

SQL Server MVP, Brussels

Consultant, speaker, trainer, PASS V-Chapter Leader

Managing partner de www.ShareQL.com

SQL Server since 1999

Blog: http://thesqlgrrrl.wordpress.com/

[email protected]

@thesqlgrrrl

Isabelle Van Campenhoudt

globalfrench.sqlpass.org

Page 5: Make your SharePoint  fly by tuning and optimizing SQL Server

Credits

Serge Luca

Accidental DBA

IsabelleVan Campenhoudt

SQL guru

Page 6: Make your SharePoint  fly by tuning and optimizing SQL Server

Agenda

Page 7: Make your SharePoint  fly by tuning and optimizing SQL Server

Agenda

Explain Basic Concepts

Plan for long term performance

Optimal Configuration

Maintenance

Measure & Improve

Conclusions

Explain

Plan

Configure

Maintain

Measure

Page 8: Make your SharePoint  fly by tuning and optimizing SQL Server

Basic Concepts

Page 9: Make your SharePoint  fly by tuning and optimizing SQL Server

SharePoint databases

100% of SharePoint content stored in SQL Server

Farm Configuration information stored in configuration db

Central Administration content stored in own content db

Most Service Applications have at least one db

All Web Applications have at least one content db

Farm can have many databases : >20

Explain

Source : Brian Alderman, modified

Page 10: Make your SharePoint  fly by tuning and optimizing SQL Server

SQL Server basic concepts

System databases

Master : similar to the SP configDB

Model : templatefor other dbs

Tempdb : temporarily results

Msdb : for automation

User databases The SharePoint databases

Explain

Source : Brian Alderman, modified

Page 11: Make your SharePoint  fly by tuning and optimizing SQL Server

.MDFCheckpoint.LDF

Data

Data

Simple Recovery Model

AddContent

Content Database

instructions

instructions

Explain

Page 12: Make your SharePoint  fly by tuning and optimizing SQL Server

.MDFCheckpoint.LDF

Data

Data

Full Recovery Model

AddContent

Content Database

instructions

instructions

Explain

Page 13: Make your SharePoint  fly by tuning and optimizing SQL Server

Plan for long term performances

Page 14: Make your SharePoint  fly by tuning and optimizing SQL Server

Optimize Resources

CPU RAM DISK Network

Page 15: Make your SharePoint  fly by tuning and optimizing SQL Server

Quick Win : NTFS Allocation Unit Size

64K is optimal, 4K = 30% Performance

Penalty (data files, not log files)

Use chkdsk <drive>to Verify

Use Format to Configure:

• Format <drive> /Q /FS:NTFS /A:64K /V:<volume> /Y

Page 16: Make your SharePoint  fly by tuning and optimizing SQL Server

Must Win: Network latency

Network (dedicated subnet for SQL)

Latency between web front ends and SQL

Server

• Mandatory for stretched farm, but good practice:

• < 1 ms during10 minutes (1% failure max)

• 1 Giga bits / sec

• Recommended if mirroring or Always On Sync (see later)

Use Alex Strachan

PowerShell scripts !!!

Page 17: Make your SharePoint  fly by tuning and optimizing SQL Server

Disks: Volume but also IOPS

Because they need to know…

As part of capacityplan

Determine how manyGB you need

->Talk to the DBA & Capacity Manager

Determine how muchIOPS you need

->Talk to the SAN team

Page 18: Make your SharePoint  fly by tuning and optimizing SQL Server

Content DB volume & Site Collections

Site Collections only reside in one database

Content database contains multiple site collections (2,000 Default Setting)

If Site Collection > 100GB store in own content database

•Soft limit maximum size <= 200 GB

Page 19: Make your SharePoint  fly by tuning and optimizing SQL Server

Databases consume disk throughputDatabase files IOPS requirements Typical load on I/O subsystem. Optimization

TempDB High 2 IOPS/GB Write

Transaction Log High 2 IOPS/GB Write

Content DB High0.5-0.75 IOPS/GB 4 TB supported: 0.25 IOPS/GB , ideally: 2 IOPS/GB

Read

Search Crawl database Medium to high10 IOPS per 1 document per second (DPS) crawl rate.

Write

Search Link database Medium10 IOPS per 1 million items in the search index.

Search Analytics

reporting database Medium Not applicable.

Search administration

databaseLow Not applicable.

Page 20: Make your SharePoint  fly by tuning and optimizing SQL Server

How can you check if you SAN support these IOPS ?

• IOMeter (free)

• SQLIO (free)

• Discuss with SAN team …

• In production: resource intensive

• Test with a file > than SAN cache

• Test reading/writing , random 64k (for data)and sequential (for transaction log)

Page 21: Make your SharePoint  fly by tuning and optimizing SQL Server

Installation & Configuration

Page 22: Make your SharePoint  fly by tuning and optimizing SQL Server

Installing SQL ServerFor SharePoint 2013:

• SQL Server 2008 R2 SP1

• SQL Server 2012 (SP1 for BI)

• SQL Server 2014 (SP2013 SP1 & April CU)

For SharePoint 2016:

• SQL Server 2014

• SQL Server 2016

• SQL Server 2017 (Win)

Don’t install SSMS on the SQL Server computer

Use named instances

\ SharePointUse a dedicated instance

Run the service with a Managed account

No specific permission,

Use SQL configuration manager ---IFI

Page 23: Make your SharePoint  fly by tuning and optimizing SQL Server

Collation settings

Latin1_General_CI_AS_KS_WS

for SharePoint databases

Any CI collation is supportedfor tempDBs, master Latin1_xxx_ is recommended

SP uses this collation when itcreates its own db

Cannot be changed after the setup !!!

Page 24: Make your SharePoint  fly by tuning and optimizing SQL Server

Server Properties

Max degree of parallelism

Maxdop=1

Page 25: Make your SharePoint  fly by tuning and optimizing SQL Server

Memory Limits

Specify memory limits

Page 26: Make your SharePoint  fly by tuning and optimizing SQL Server

Tips

Use alias for the connection string

• Client alias or DNS alias (preferred)

Good practice : every SP Content db must becreated (and documented) by a DBA after a strict capacity plan

Page 27: Make your SharePoint  fly by tuning and optimizing SQL Server

Recovery – related to your RPO & Backups

Model db : recoverymodel = template

Tempdb : recoverymodel = simple

SharePoint DB : recovery model ?

Contend DB = full

Config DB= simple

Services App DBs= itdepends :

• http://technet.microsoft.com/en-

us/library/cc678868.aspx

UAT & Production

Always On Availability groups: recovery = full !

Developer Workstation /Test Farm:

recovery = simple!

Page 28: Make your SharePoint  fly by tuning and optimizing SQL Server

Model DB settings is the template

Increase Initial size Increase Autogrowth

(MB , not %)

Page 29: Make your SharePoint  fly by tuning and optimizing SQL Server

TempDB settings : crucial

Configure Tempdb files

#files = #cores

Max 8 if #cores > 8

Same size for every file

Configure Tempdb Size

At Least 10% of Biggest Content DB’s Size

Tempdb Database Settings

Increase Initial Size Setting

Increase Autogrowth Settings (Use MB Not %)

Use Simple Recovery Model

Place on Different Drive Than Content Databases

Page 30: Make your SharePoint  fly by tuning and optimizing SQL Server

Files placement

Priority (Fastest to Slowest Drive)

Tempdb Data and Transaction Log Files

Content DataBase Transaction Log Files

Search Database Data Files

Content Database Data Files

Use Multiple Data Files for Content and Search DB’s

Distribute Equally-Sized Data Files Across Separate Disks

Number of Data Files Should Be <= Number of Processor Cores

Page 31: Make your SharePoint  fly by tuning and optimizing SQL Server

Installing SharePoint

Setup account

(sp-install)

Must be:(SQL Server)

DBcreator

(SQL Server)

Securityadmin

Local admin (SP Machines only) Domain account

Page 32: Make your SharePoint  fly by tuning and optimizing SQL Server

Using SQL Server Resource Governor to optimize Search Database usage

Part of SQL Server Enterprise (since SQL 2008)

Limits CPU and memory usage on some DBs (and IO in SQL Server 2014)

• like search DBs

Allow less CPU & mem & IO usage during work hours

Allow more CPU & mem & IO usage during off hours

Page 33: Make your SharePoint  fly by tuning and optimizing SQL Server

Maintenance

Page 34: Make your SharePoint  fly by tuning and optimizing SQL Server

SharePoint: Health Analyzer

Job will defragment the indices

If fragment > 30% & rowcount > 10.000

Job will update statistics

AUTO_CREATE_STATISTICS OFF

Page 35: Make your SharePoint  fly by tuning and optimizing SQL Server

DBA: Verify Integrity of databases

DBCC CheckDB

Check REPAIR_REBUILD Option to Fix Errors (Not

Always Possible)REPAIR_ALLOW_DATA_LOSS Not Supported

Time & Resource Consuming Operation, Run During Non-Peak

Hours

For Very Large DBs consider using option

MAXDOP=1

Page 36: Make your SharePoint  fly by tuning and optimizing SQL Server

Tools & Troubleshooting

Page 37: Make your SharePoint  fly by tuning and optimizing SQL Server

Measuring is the key

Measure the compliance

Measure the performance

Page 38: Make your SharePoint  fly by tuning and optimizing SQL Server

Measure the compliance

SQL configuration

Disks placements

Databases configuration

Correct maintenance

SPDOCKITSYSKITSQL Policies& Custom ReportingKANKURUMicrosoft BPACustom PowerShellDBA ToolsExtended Properties

Page 39: Make your SharePoint  fly by tuning and optimizing SQL Server

Measure the performanceCPU

I/O

Network

Memory

Run a trace of Performance Counters (24 hours)

Provides templates of accuratecounters

Analyse regarding thresholds

Generate meaningfull reports

Map Toolkit

Performance Analysis of Logs (PAL)

SCOM

You need a Baseline

Page 40: Make your SharePoint  fly by tuning and optimizing SQL Server

Principal SQL Counters to measureCounters: Should be:

Memory: Available Bytes At least 4 GB for the system

Logical Disk: Disk sec/Read Between 15 and 25 ms

Logical Disk: Disk sec/Write Between 15 and 25 ms

Process: cpu/working set/io SQLsrve.exe % other processes

Processor Max 40%

SQL Server: Buffer Manager: Buffer Cache Hit

Ratio

>97%

SQL Server: Buffer Manager: Page life expectancy > 300 sec (but do a baseline)

Page 41: Make your SharePoint  fly by tuning and optimizing SQL Server

Performances interpretation (source : PAL)

Page 42: Make your SharePoint  fly by tuning and optimizing SQL Server

Stress your system to not have it stress you

Page 43: Make your SharePoint  fly by tuning and optimizing SQL Server

A Dashboard is useful

TIP:I use SQL Diagnostic Queries queries in

Power BI

Page 44: Make your SharePoint  fly by tuning and optimizing SQL Server

Monitor your System on a daily basis

• Continuous monitor• Rely on SQL monitoring

• Less is More• Stick to the basics

•Notifications• Adapt

• Reactions• Have a strong reaction chain

Page 45: Make your SharePoint  fly by tuning and optimizing SQL Server

Conclusions

Page 46: Make your SharePoint  fly by tuning and optimizing SQL Server

Conclusions

Explain

Plan

Configure

Maintain

Measure

Build strong relations with: DBA SAN Network Monitoring Team

Page 47: Make your SharePoint  fly by tuning and optimizing SQL Server

Useful links

• http://www.iometer.org/

• https://dbatools.io/

• http://kankuru.com/

• https://pal.codeplex.com/

• https://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-november-2017/

• https://www.spdockit.com/

• https://www.syskit.com/

Page 48: Make your SharePoint  fly by tuning and optimizing SQL Server

Merci !

• @thesqlgrrrl @sergeluca