Perfmon And Profiler 101
-
Upload
quest-software -
Category
Technology
-
view
2.866 -
download
5
description
Transcript of Perfmon And Profiler 101
![Page 1: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/1.jpg)
© 2008 Quest Software, Inc. ALL RIGHTS RESERVED.
Perfmon and Profiler 101
![Page 2: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/2.jpg)
About Me: Brent Ozar• SQL Server Expert for
Quest Software• Former SQL DBA• Managed >80tb SAN,
VMware• Dot-com-crash
experience• Specializes in
performance tuning
![Page 3: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/3.jpg)
Today’s Agenda• The Civic & Godzilla• Metrics, Trace,
Mitigations• Taking Before and
After Pictures• Helpful Tools• Sample Scenarios• Resources and Q&A
![Page 4: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/4.jpg)
If You Don’t Need to Go Fast…
Photo Licensed With Creative Commons From http://flickr.com/photos/stevekeys/2755142278/
![Page 5: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/5.jpg)
But The Faster You Want To Go
![Page 6: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/6.jpg)
The More You Have To Measure
![Page 7: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/7.jpg)
Windows “Check Engine” Light
![Page 8: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/8.jpg)
And If You Wanna Go Fast:
![Page 9: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/9.jpg)
Two Approaches to Detection• Exceptions Monitoring:
– Check Engine Light– Reactive Actions
• Proactive Monitoring: – Detailed Gauges– Preventative Actions
![Page 10: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/10.jpg)
Metrics-Trace-Mitigation Process
![Page 11: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/11.jpg)
Where Do We Start?
![Page 12: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/12.jpg)
Capture Metrics With Perfmon• Performance Monitor, aka Perfmon• Ships with all Windows versions• Polls any server from your desktop• Pulls performance metrics• Writes them to a file• Requires some OS permissions• Does not include alerts or analytics
![Page 13: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/13.jpg)
13
![Page 14: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/14.jpg)
Memory Counters• Memory – Available Mbytes• Paging File - % Usage• SQLServer:Buffer Manager –
– Buffer cache hit ratio– Page life expectancy
• SQLServer:Memory Manager – Memory Grants Pending
![Page 15: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/15.jpg)
Storage Metrics: Physical Disk• Avg. Disk Queue Length• Avg. Disk sec/Read• Avg. Disk sec/Write• Disk Reads/sec• Disk Writes/sec• % Disk Time
![Page 16: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/16.jpg)
CPU & Other Metrics• Processor - % Processor Time• System – Processor Queue Length• SQLServer:General Statistics –
User Connections
![Page 17: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/17.jpg)
17
The Raw Output: CSV Files
![Page 18: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/18.jpg)
18
Adding Analytical Formulas
![Page 19: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/19.jpg)
19
That’s a Lot of Zeroes!
![Page 20: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/20.jpg)
20
Sorting High to Low
![Page 21: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/21.jpg)
What To Look For, In Order• System – Processor Queue Length• Memory – Available Mbytes• Lock pages in memory!
![Page 22: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/22.jpg)
What To Look For Next• Disk metrics on the page file drive• Disk metrics on the log file drive• Disk metrics on the data file drive• Disk metrics on the TempDB drive
![Page 23: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/23.jpg)
Got Everything on One Drive?• Narrow it down with the DMV
sys.dm_io_virtual_file_stats
![Page 24: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/24.jpg)
Capture Queries with a Trace
![Page 25: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/25.jpg)
Columns to Capture
What’s Going On• Text Data• DatabaseID and/or
DatabaseName• Login Name• Host Name• Application Name
What The Impact Was• CPU• Reads• Writes• Duration• Start Time• End Time
![Page 26: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/26.jpg)
Profiler’s Results: A Trace Table
![Page 27: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/27.jpg)
Order By Duration Descending
![Page 28: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/28.jpg)
Casting and Grouping
![Page 29: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/29.jpg)
Correlate Metrics & Trace• Show a cause and effect relationship• Fields to mentally “join” on:
– Date/Time ranges– CPU– Reads/Writes– Duration
![Page 30: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/30.jpg)
Metrics-Trace-Mitigation Process
![Page 31: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/31.jpg)
If Our Servers Were Houses…
Before
After
![Page 32: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/32.jpg)
Consistent and Repeatable• 100 users accessing the web site• Closing a typical financial period• 10 users running a report• Importing 100,000 records for a nightly
ETL process• Think scripts, think load generation tool• Capture statistics during test run
![Page 33: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/33.jpg)
When To Take A Picture• Adding new hardware• Installing a SQL
Server service pack• Changing storage
configurations• New application
versions• Every quarter
Before
After
![Page 34: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/34.jpg)
Plus Monitoring For…• Things break• Populations change
over time• Budgeting• Need to enforce
standards• We’re not the only
ones working on the house
Before
After
![Page 35: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/35.jpg)
Save Perfmon & Profiler Data• Central file share• Even better: in a database• Name by server, by date• Revisit every budget season• Use for new hire training
![Page 36: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/36.jpg)
Tool: Performance Dashboard
![Page 37: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/37.jpg)
Tool: Data Mining
![Page 38: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/38.jpg)
Table Analysis Tools For The Cloud
![Page 39: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/39.jpg)
Detect Categories of Load
![Page 40: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/40.jpg)
Works for Profiler Results Too
![Page 41: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/41.jpg)
Tool: ClearTrace
![Page 42: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/42.jpg)
Cleans Up Queries
![Page 43: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/43.jpg)
Sample Problem #1• Metrics tell us:
– Very high disk queue lengths on data drive
• Trace tells us:– Report queries doing
table scans w/o indexes– Many scheduled reports
run simultaneously
![Page 44: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/44.jpg)
Ways We Can Mitigate It• Add covering indexes• Modify existing indexes• Add hard drives to the data file array• Add memory to cache scanned tables• Run reports serially, not all at once
![Page 45: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/45.jpg)
Sample Problem #2• Metrics tell us:
– Page file drive queue lengths average >20
– Page file use averages >1%– Available memory averages less
than 250mb
• Trace tells us:– No unusual queries
![Page 46: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/46.jpg)
Memory Configuration
![Page 47: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/47.jpg)
Ways We Can Mitigate It• Add memory and enable AWE/PAE• Add memory and upgrade to 64-bit• Move the app to its own server• Reduce SQL’s min/max memory sizes
![Page 48: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/48.jpg)
Sample Problem #3• Metric looks OK, but
every 15 minutes:– Long drive queues on the
log file drive– Page life expectancy
drops near zero– Network traffic jumps
• Trace tells us:– Transaction log backups
are running
![Page 49: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/49.jpg)
Ways We Can Mitigate It• Stop doing log backups• Put the databases in simple mode• Add drives to the transaction log array• Throttle the transaction log backups
![Page 50: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/50.jpg)
Sample Problem #4• Metrics tell us:
– CPU average is high – Disk, memory look OK
• Trace tells us:– Queries are using
cursors– Operating on
individual records, not sets
![Page 51: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/51.jpg)
How We Can Mitigate It• Buy really fast processors• Spend a lot on licensing• Change cursor to set-based query
![Page 52: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/52.jpg)
Wrapping Things Up• Double-check the event log first• Don’t get overwhelmed: focus with the
Metric – Trace – Mitigation process• Show a clear cause and effect• Use pro tools to get an edge
![Page 53: Perfmon And Profiler 101](https://reader031.fdocuments.us/reader031/viewer/2022012922/556207f8d8b42a00138b45cf/html5/thumbnails/53.jpg)
Resources On The Web• My blog about Perfmon:
www.BrentOzar.com/perfmon• Excel Table Analysis Tools for the Cloud:
www.SQLServerDataMining.com/cloud• ClearTrace:
http://www.cleardata.biz/cleartrace/• SQL Server community:
SQLServerPedia.com