SlideShare uma empresa Scribd logo
1 de 53
Perfmon and Profiler 101




                           © 2008 Quest Software, Inc. ALL RIGHTS RESERVED.
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
Today’s Agenda
• The Civic& Godzilla
• Metrics, Trace,
  Mitigations
• Taking Before and
  After Pictures
• Helpful Tools
• Sample Scenarios
• Resources and Q&A
If You Don’t Need to Go Fast…




    Photo Licensed With Creative Commons From http://flickr.com/photos/stevekeys/2755142278/
But The Faster You Want To Go
The More You Have To Measure
Windows “Check Engine” Light
And If You Wanna Go Fast:
Two Approaches to Detection
• Exceptions Monitoring:
  – Check Engine Light
  – Reactive Actions
• Proactive Monitoring:
  – Detailed Gauges
  – Preventative Actions
Metrics-Trace-Mitigation Process

               Capture
               Metrics




                            Capture
        Act
                             Trace




               Define
              Mitigations
Where Do We Start?
            Hardware

            Windows

            SQL Server

              Tables,
             Indexes



              Query
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
12
Memory Counters
• Memory – Available Mbytes
• Paging File - % Usage
• SQLServer:Buffer Manager –
  – Buffer cache hit ratio
  – Page life expectancy
• SQLServer:Memory Manager –
  Memory Grants Pending
Storage Metrics: Physical Disk
•   Avg. Disk Queue Length
•   Avg. Disk sec/Read
•   Avg. Disk sec/Write
•   Disk Reads/sec
•   Disk Writes/sec
•   % Disk Time
CPU & Other Metrics
• Processor - % Processor Time
• System – Processor Queue Length
• SQLServer:General Statistics –
  User Connections
The Raw Output: CSV Files




                            16
Adding Analytical Formulas




                             17
That’s a Lot of Zeroes!




                          18
Sorting High to Low




                      19
What To Look For, In Order
• System – Processor Queue Length
• Memory – Available Mbytes
• Lock pages in memory!
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
Got Everything on One Drive?
• Narrow it down with the DMV
  sys.dm_io_virtual_file_stats
Capture Queries with a Trace
Columns to Capture

What’s Going On       What The Impact Was
• Text Data           • CPU
• DatabaseID and/or   • Reads
  DatabaseName        • Writes
• Login Name          • Duration
• Host Name           • Start Time
• Application Name    • End Time
Profiler’s Results: A Trace Table
Order By Duration Descending
Casting and Grouping
Correlate Metrics & Trace
• Show a cause and effect relationship
• Fields to mentally “join” on:
  –   Date/Time ranges
  –   CPU
  –   Reads/Writes
  –   Duration
Metrics-Trace-Mitigation Process

               Capture
               Metrics




                            Capture
        Act
                             Trace




               Define
              Mitigations
If Our Servers Were Houses…
       Before




       After
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
When To Take A Picture
                        Before
• Adding new hardware
• Installing a SQL
  Server service pack
• Changing storage
  configurations        After

• New application
  versions
• Every quarter
Plus Monitoring For…
                        Before
• Things break
• Populations change
  over time
• Budgeting
• Need to enforce       After

  standards
• We’re not the only
  ones working on the
  house
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
Tool: Performance Dashboard
Tool: Data Mining
Table Analysis Tools For The Cloud
Detect Categories of Load
Works for Profiler Results Too
Tool: ClearTrace
Cleans Up Queries
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
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
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
Memory Configuration

   Server: 4gb ram

 OS:       SQL:        App:
 1gb       3gb         1gb
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
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
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
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
How We Can Mitigate It
• Buy really fast processors
• Spend a lot on licensing
• Change cursor to set-based query
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
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

Mais conteúdo relacionado

Mais procurados

ProxySQL Tutorial - PLAM 2016
ProxySQL Tutorial - PLAM 2016ProxySQL Tutorial - PLAM 2016
ProxySQL Tutorial - PLAM 2016
Derek Downey
 
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Severalnines
 

Mais procurados (20)

Why new hardware may not make SQL Server faster
Why new hardware may not make SQL Server fasterWhy new hardware may not make SQL Server faster
Why new hardware may not make SQL Server faster
 
Revisiting HTTP/2
Revisiting HTTP/2Revisiting HTTP/2
Revisiting HTTP/2
 
HBase tales from the trenches
HBase tales from the trenchesHBase tales from the trenches
HBase tales from the trenches
 
The Magic of Tuning in PostgreSQL
The Magic of Tuning in PostgreSQLThe Magic of Tuning in PostgreSQL
The Magic of Tuning in PostgreSQL
 
Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web Application
 
12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL
 
Web acceleration mechanics
Web acceleration mechanicsWeb acceleration mechanics
Web acceleration mechanics
 
HTTP/2: What no one is telling you
HTTP/2: What no one is telling youHTTP/2: What no one is telling you
HTTP/2: What no one is telling you
 
Proxysql ha plam_2016_2_keynote
Proxysql ha plam_2016_2_keynoteProxysql ha plam_2016_2_keynote
Proxysql ha plam_2016_2_keynote
 
The have no fear guide to virtualizing databases
The have no fear guide to virtualizing databasesThe have no fear guide to virtualizing databases
The have no fear guide to virtualizing databases
 
Http caching basics
Http caching basicsHttp caching basics
Http caching basics
 
ProxySQL Tutorial - PLAM 2016
ProxySQL Tutorial - PLAM 2016ProxySQL Tutorial - PLAM 2016
ProxySQL Tutorial - PLAM 2016
 
Altitude San Francisco 2018: Programming the Edge
Altitude San Francisco 2018: Programming the EdgeAltitude San Francisco 2018: Programming the Edge
Altitude San Francisco 2018: Programming the Edge
 
Postgres in Amazon RDS
Postgres in Amazon RDSPostgres in Amazon RDS
Postgres in Amazon RDS
 
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
 
Advanced HTTP Caching
Advanced HTTP CachingAdvanced HTTP Caching
Advanced HTTP Caching
 
Apache Samza - New features in the upcoming Samza release 0.10.0
Apache Samza - New features in the upcoming Samza release 0.10.0Apache Samza - New features in the upcoming Samza release 0.10.0
Apache Samza - New features in the upcoming Samza release 0.10.0
 
High Performance Networking
High Performance NetworkingHigh Performance Networking
High Performance Networking
 
How Time To First Byte (TTFB) Impacts Your Site’s Performance
How Time To First Byte (TTFB) Impacts Your Site’s PerformanceHow Time To First Byte (TTFB) Impacts Your Site’s Performance
How Time To First Byte (TTFB) Impacts Your Site’s Performance
 

Destaque

Radview WebLOAD
Radview WebLOADRadview WebLOAD
Radview WebLOAD
amit singh
 
Basic concepts of computer Networking
Basic concepts of computer NetworkingBasic concepts of computer Networking
Basic concepts of computer Networking
Hj Habib
 
FireWall
FireWallFireWall
FireWall
rubal_9
 
BASIC CONCEPTS OF COMPUTER NETWORKS
BASIC CONCEPTS OF COMPUTER NETWORKS BASIC CONCEPTS OF COMPUTER NETWORKS
BASIC CONCEPTS OF COMPUTER NETWORKS
Kak Yong
 
Lan, man and wan ppt final
Lan, man and wan ppt finalLan, man and wan ppt final
Lan, man and wan ppt final
Arushi Garg
 

Destaque (20)

Radview WebLOAD
Radview WebLOADRadview WebLOAD
Radview WebLOAD
 
Cloud Monitoring
Cloud MonitoringCloud Monitoring
Cloud Monitoring
 
30+ MS Excel Hacks & Tips That Even Your Grandma Would Love
30+ MS Excel Hacks & Tips That Even Your Grandma Would Love30+ MS Excel Hacks & Tips That Even Your Grandma Would Love
30+ MS Excel Hacks & Tips That Even Your Grandma Would Love
 
Cloud Performance Testing with LoadRunner
Cloud Performance Testing with LoadRunnerCloud Performance Testing with LoadRunner
Cloud Performance Testing with LoadRunner
 
Hp monitoring tool site scope
Hp monitoring tool  site scopeHp monitoring tool  site scope
Hp monitoring tool site scope
 
SAP Performance Testing Best Practice Guide v1.0
SAP Performance Testing Best Practice Guide v1.0SAP Performance Testing Best Practice Guide v1.0
SAP Performance Testing Best Practice Guide v1.0
 
What is Application Performance Management?
What is Application Performance Management?What is Application Performance Management?
What is Application Performance Management?
 
Subnetting Basics Tutorial
Subnetting Basics TutorialSubnetting Basics Tutorial
Subnetting Basics Tutorial
 
SAP Basics
SAP BasicsSAP Basics
SAP Basics
 
CCNA TCP/IP
CCNA TCP/IPCCNA TCP/IP
CCNA TCP/IP
 
Sql Injection Myths and Fallacies
Sql Injection Myths and FallaciesSql Injection Myths and Fallacies
Sql Injection Myths and Fallacies
 
CCNA IP Addressing
CCNA IP AddressingCCNA IP Addressing
CCNA IP Addressing
 
Network ppt
Network pptNetwork ppt
Network ppt
 
Basic concepts of computer Networking
Basic concepts of computer NetworkingBasic concepts of computer Networking
Basic concepts of computer Networking
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
Ip address and subnetting
Ip address and subnettingIp address and subnetting
Ip address and subnetting
 
FireWall
FireWallFireWall
FireWall
 
SAP for Beginners
SAP for BeginnersSAP for Beginners
SAP for Beginners
 
BASIC CONCEPTS OF COMPUTER NETWORKS
BASIC CONCEPTS OF COMPUTER NETWORKS BASIC CONCEPTS OF COMPUTER NETWORKS
BASIC CONCEPTS OF COMPUTER NETWORKS
 
Lan, man and wan ppt final
Lan, man and wan ppt finalLan, man and wan ppt final
Lan, man and wan ppt final
 

Semelhante a Perfmon And Profiler 101

Perfmon And Profiler 101
Perfmon And Profiler 101Perfmon And Profiler 101
Perfmon And Profiler 101
Quest Software
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1
sqlserver.co.il
 

Semelhante a Perfmon And Profiler 101 (20)

Perfmon And Profiler 101
Perfmon And Profiler 101Perfmon And Profiler 101
Perfmon And Profiler 101
 
Netcetera Proactive Management Service
Netcetera Proactive Management ServiceNetcetera Proactive Management Service
Netcetera Proactive Management Service
 
SharePoint 2013 Performance Analysis - Robi Vončina
SharePoint 2013 Performance Analysis - Robi VončinaSharePoint 2013 Performance Analysis - Robi Vončina
SharePoint 2013 Performance Analysis - Robi Vončina
 
Performance Whackamole (short version)
Performance Whackamole (short version)Performance Whackamole (short version)
Performance Whackamole (short version)
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL Server
 
How To Write A SQL Server Performance Review
How To Write A SQL Server Performance ReviewHow To Write A SQL Server Performance Review
How To Write A SQL Server Performance Review
 
Scalabe MySQL Infrastructure
Scalabe MySQL InfrastructureScalabe MySQL Infrastructure
Scalabe MySQL Infrastructure
 
Lifting the Blinds: Monitoring Windows Server 2012
Lifting the Blinds: Monitoring Windows Server 2012Lifting the Blinds: Monitoring Windows Server 2012
Lifting the Blinds: Monitoring Windows Server 2012
 
Magee Dday2 Fixing App Performance Italiano
Magee Dday2 Fixing App Performance ItalianoMagee Dday2 Fixing App Performance Italiano
Magee Dday2 Fixing App Performance Italiano
 
Qure Tech Presentation
Qure Tech PresentationQure Tech Presentation
Qure Tech Presentation
 
SQLite3
SQLite3SQLite3
SQLite3
 
Monitoring @haptik
Monitoring @haptikMonitoring @haptik
Monitoring @haptik
 
YAPC2007 Remote System Monitoring (w. Notes)
YAPC2007 Remote System Monitoring (w. Notes)YAPC2007 Remote System Monitoring (w. Notes)
YAPC2007 Remote System Monitoring (w. Notes)
 
Tips on High Performance Server Programming
Tips on High Performance Server ProgrammingTips on High Performance Server Programming
Tips on High Performance Server Programming
 
Tools and Tips to Diagnose Performance Issues
Tools and Tips to Diagnose Performance IssuesTools and Tips to Diagnose Performance Issues
Tools and Tips to Diagnose Performance Issues
 
Whats New In Silverlight 3
Whats New In Silverlight 3Whats New In Silverlight 3
Whats New In Silverlight 3
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
 
Testing pc’s performance
Testing pc’s performanceTesting pc’s performance
Testing pc’s performance
 
SharePoint Performance Monitoring with Sean P. McDonough
SharePoint Performance Monitoring with Sean P. McDonoughSharePoint Performance Monitoring with Sean P. McDonough
SharePoint Performance Monitoring with Sean P. McDonough
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1
 

Mais de Quest Software (9)

Virtualization and SAN Basics for DBAs
Virtualization and SAN Basics for DBAsVirtualization and SAN Basics for DBAs
Virtualization and SAN Basics for DBAs
 
Perfmon And Profiler 201
Perfmon And Profiler 201Perfmon And Profiler 201
Perfmon And Profiler 201
 
Advanced Index Tuning for SQL Server
Advanced Index Tuning for SQL ServerAdvanced Index Tuning for SQL Server
Advanced Index Tuning for SQL Server
 
SQL Server On SANs
SQL Server On SANsSQL Server On SANs
SQL Server On SANs
 
Disaster Recovery 101
Disaster Recovery 101Disaster Recovery 101
Disaster Recovery 101
 
CMDB Basics
CMDB BasicsCMDB Basics
CMDB Basics
 
Get Your Boss To Say Yes
Get Your Boss To Say YesGet Your Boss To Say Yes
Get Your Boss To Say Yes
 
Sql Server Service Broker In The Real World
Sql Server Service Broker In The Real WorldSql Server Service Broker In The Real World
Sql Server Service Broker In The Real World
 
Advanced Index Tuning
Advanced Index TuningAdvanced Index Tuning
Advanced Index Tuning
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Perfmon And Profiler 101

  • 1. Perfmon and Profiler 101 © 2008 Quest Software, Inc. ALL RIGHTS RESERVED.
  • 2. 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
  • 3. Today’s Agenda • The Civic& Godzilla • Metrics, Trace, Mitigations • Taking Before and After Pictures • Helpful Tools • Sample Scenarios • Resources and Q&A
  • 4. If You Don’t Need to Go Fast… Photo Licensed With Creative Commons From http://flickr.com/photos/stevekeys/2755142278/
  • 5. But The Faster You Want To Go
  • 6. The More You Have To Measure
  • 8. And If You Wanna Go Fast:
  • 9. Two Approaches to Detection • Exceptions Monitoring: – Check Engine Light – Reactive Actions • Proactive Monitoring: – Detailed Gauges – Preventative Actions
  • 10. Metrics-Trace-Mitigation Process Capture Metrics Capture Act Trace Define Mitigations
  • 11. Where Do We Start? Hardware Windows SQL Server Tables, Indexes Query
  • 12. 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
  • 13. 12
  • 14. Memory Counters • Memory – Available Mbytes • Paging File - % Usage • SQLServer:Buffer Manager – – Buffer cache hit ratio – Page life expectancy • SQLServer:Memory Manager – Memory Grants Pending
  • 15. Storage Metrics: Physical Disk • Avg. Disk Queue Length • Avg. Disk sec/Read • Avg. Disk sec/Write • Disk Reads/sec • Disk Writes/sec • % Disk Time
  • 16. CPU & Other Metrics • Processor - % Processor Time • System – Processor Queue Length • SQLServer:General Statistics – User Connections
  • 17. The Raw Output: CSV Files 16
  • 19. That’s a Lot of Zeroes! 18
  • 20. Sorting High to Low 19
  • 21. What To Look For, In Order • System – Processor Queue Length • Memory – Available Mbytes • Lock pages in memory!
  • 22. 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
  • 23. Got Everything on One Drive? • Narrow it down with the DMV sys.dm_io_virtual_file_stats
  • 25. Columns to Capture What’s Going On What The Impact Was • Text Data • CPU • DatabaseID and/or • Reads DatabaseName • Writes • Login Name • Duration • Host Name • Start Time • Application Name • End Time
  • 26. Profiler’s Results: A Trace Table
  • 27. Order By Duration Descending
  • 29. Correlate Metrics & Trace • Show a cause and effect relationship • Fields to mentally “join” on: – Date/Time ranges – CPU – Reads/Writes – Duration
  • 30. Metrics-Trace-Mitigation Process Capture Metrics Capture Act Trace Define Mitigations
  • 31. If Our Servers Were Houses… Before After
  • 32. 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
  • 33. When To Take A Picture Before • Adding new hardware • Installing a SQL Server service pack • Changing storage configurations After • New application versions • Every quarter
  • 34. Plus Monitoring For… Before • Things break • Populations change over time • Budgeting • Need to enforce After standards • We’re not the only ones working on the house
  • 35. 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
  • 38. Table Analysis Tools For The Cloud
  • 40. Works for Profiler Results Too
  • 43. 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
  • 44. 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
  • 45. 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
  • 46. Memory Configuration Server: 4gb ram OS: SQL: App: 1gb 3gb 1gb
  • 47. 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
  • 48. 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
  • 49. 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
  • 50. 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
  • 51. How We Can Mitigate It • Buy really fast processors • Spend a lot on licensing • Change cursor to set-based query
  • 52. 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
  • 53. 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