Troubleshooting SQL Server

2,869 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,869
On SlideShare
0
From Embeds
0
Number of Embeds
20
Actions
Shares
0
Downloads
115
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Troubleshooting SQL Server

    1. 1. Troubleshooting SQL Server Stephen Rose- MCSE, MCT, MCSA, MCP+I Microsoft MVP- Connected Systems Developer
    2. 2. Agenda <ul><li>Who Am I? </li></ul><ul><li>Where Do I Start? </li></ul><ul><li>Case Study- MS Society of Canada </li></ul><ul><li>Optimal Environment </li></ul><ul><li>Performance Monitor (PerfMon) </li></ul><ul><li>Optimizing SQL </li></ul><ul><li>Conclusions </li></ul><ul><li>Q and A </li></ul>
    3. 3. Who Am I? <ul><ul><li>Stephen Rose </li></ul></ul><ul><ul><ul><li>Partner /Network Architect with Odyssey Consulting Group </li></ul></ul></ul><ul><ul><ul><li>MCSE, MCT, MCSA, MCP+I </li></ul></ul></ul><ul><ul><ul><li>2007 Microsoft Most Valuable Professional – Networking </li></ul></ul></ul><ul><ul><ul><li>Certified in Windows NT, 2000, and 2003 </li></ul></ul></ul><ul><ul><ul><li>15 years of Tech Experience </li></ul></ul></ul><ul><ul><ul><li>Technical Blogger with Fast Company Magazine </li></ul></ul></ul><ul><ul><ul><ul><li>http://blog.fastcompany.com/experts </li></ul></ul></ul></ul><ul><ul><ul><li>Personal Tech Blog @ </li></ul></ul></ul><ul><ul><ul><ul><li>http://mcsegeek.wordpress.com </li></ul></ul></ul></ul><ul><ul><ul><li>Member of the UCSD Advisory Board </li></ul></ul></ul><ul><ul><ul><li>Member of INETA.org Board </li></ul></ul></ul>
    4. 4. Let’s begin
    5. 5. Case Study Background <ul><li>Odyssey Consulting Group was contracted by the Multiple Sclerosis Society of Canada to help redesign and optimize their internal network systems to better support their new online fundraising portal. </li></ul><ul><li>Technologies like web farms, load balancing, SQL clustering and server virtualization were introduced to help meet MS Society meet their needs but the big issue was SQL and it’s connections to some legacy systems. </li></ul>
    6. 6. Optimal Environment <ul><li>Disc Array </li></ul><ul><ul><li>Small Disks = Faster </li></ul></ul><ul><ul><li>10 30GB Disks rather than 2 150GB </li></ul></ul><ul><ul><li>Seek Time, Latency, Search </li></ul></ul><ul><ul><li>10k – 15k </li></ul></ul><ul><ul><li>RAID 0+1 </li></ul></ul><ul><li>32 Bit SQL vs. 64 Bit SQL </li></ul><ul><li>Clustering </li></ul><ul><li>Server 2008 w/ SQL 2008 </li></ul><ul><li>Web Farm </li></ul><ul><li>Load Balancing </li></ul>
    7. 7. <ul><li>PerfMon which is a SNMP based performance monitoring tool. </li></ul><ul><li>PerfMon has the following chracteristics: </li></ul><ul><ul><li>High performance </li></ul></ul><ul><ul><li>It requires little cpu to run, even with more that thousand hosts being polled. </li></ul></ul>
    8. 8. MS Society of Canada
    9. 9. Network Setup
    10. 10. <ul><li>Web Server </li></ul><ul><ul><li>Dual Xeon Processor 3 GHz </li></ul></ul><ul><ul><li>2 GB RAM </li></ul></ul><ul><ul><li>2 x 72GB 10K drives (RAID 1) </li></ul></ul><ul><ul><li>Windows 2003 SP1 </li></ul></ul><ul><li>NAT-SQL-01 </li></ul><ul><ul><li>Quad Xeon MP 1.5 GHz </li></ul></ul><ul><ul><li>4 GB RAM </li></ul></ul><ul><ul><li>2x 36 GB 10K Drives RAID 1(Internal, running Windows, Page Files and SQL app only) </li></ul></ul><ul><ul><li>12 x 72 GB 15K Drives (Connected to a SAN) </li></ul></ul><ul><ul><li>RAID 10 (Running SQL data and log files) </li></ul></ul><ul><ul><li>Windows 2003 SP1 SQL 2000 SP4 </li></ul></ul>
    11. 11. <ul><li>NAT-SQL-02 </li></ul><ul><ul><ul><li>Quad Xeon MP 1.5 GHz </li></ul></ul></ul><ul><ul><ul><li>4 GB RAM </li></ul></ul></ul><ul><ul><ul><li>2 x 18 GB 10K Drives RAID 1(Internal, running Windows, Page Files and SQL app only) </li></ul></ul></ul><ul><ul><ul><li>12 x 18 GB 15K Drives (Connected to a External SCSI array) </li></ul></ul></ul><ul><ul><ul><li>RAID 10 (Running SQL data and log files) </li></ul></ul></ul><ul><ul><ul><li>Windows 2003 SP1 SQL2005 </li></ul></ul></ul>
    12. 12. <ul><li>SAN </li></ul><ul><ul><li>IBM DS4300 Expansion Unit 2 x 72GB 15K </li></ul></ul><ul><ul><ul><li>Drives for NAT-APP-03 user files </li></ul></ul></ul><ul><ul><li>RAID 1 12 x 72GB 15K </li></ul></ul><ul><ul><ul><li>Drives for NAT-SQL-01 data and log files </li></ul></ul></ul><ul><ul><li>RAID 10 2 x 72GB 15K </li></ul></ul><ul><ul><ul><li>Drives for NAT-SQL-03 data and log files </li></ul></ul></ul><ul><ul><li>RAID 1 6 x 72GB 15K </li></ul></ul><ul><ul><ul><li>Drives for VMWare </li></ul></ul></ul><ul><ul><li>RAID 5 2 SAN Switches for redundancy </li></ul></ul><ul><ul><ul><li>Connected to NAT-SQL-01 </li></ul></ul></ul><ul><ul><li>NAT-APP-03, NAT-SQL-03) </li></ul></ul><ul><ul><li>All servers have Dual HBA's for redundancy </li></ul></ul>
    13. 13. <ul><li>Network </li></ul><ul><ul><li>2 x Cisco ASA5510 Firewalls, connected to 3 SDSL and 1 ADSL internet lines (2 lines per firewall in context mode) </li></ul></ul><ul><ul><li>2 x Cisco Catalyst 3560G Core Switches (configured for failover, default gateway for network, firewalls plugged into these and linked to 3Com switches below) </li></ul></ul><ul><ul><li>VLAN's configured for routing tables </li></ul></ul>
    14. 14. <ul><li>Network </li></ul><ul><ul><li>2 x 3Com Superstack 3 4228G switches (All servers plugged directly into these along with all hubs and Rogers VPN connection) </li></ul></ul><ul><ul><li>Dual T1 line connected to 3com switches via a Cisco 1700 Series Router linking 14 remote sites for VPN </li></ul></ul>
    15. 15. Issues/Solutions
    16. 16. % of Processor Time <ul><li>Processor Usage: </li></ul><ul><li>Issue: </li></ul><ul><ul><li>The processor usage averages around 50%-70%. Processor usage should be around 20%. This shows there is not enough processor cycles to manage the data. </li></ul></ul><ul><li>Solution: </li></ul><ul><ul><li>Utilize more processors. Preferably 64 Bit capable of Hyperthreading with 64 bit SQL and 2003 OS. </li></ul></ul>
    17. 17. AT-SQL-01Processor(_Total) Processor Time
    18. 18. AT-APP-04Processor(_Total) Processor Time
    19. 19. Disk Speed <ul><li>Disk Speed: </li></ul><ul><li>Issue: </li></ul><ul><ul><li>Your average write time is around 75MS. This should hang around 20MS. Your Read time is averaging 100. It should be around 40MS. </li></ul></ul><ul><li>Solution: </li></ul><ul><ul><li>Upgrading to smaller disks (40-60GB Max) that are faster (15,000 RPM). </li></ul></ul>
    20. 20. AT-SQL-01PhysicalDisk(_Total) Disk Read Time
    21. 21. AT-APP-04PhysicalDisk(_Total) Disk Write Time
    22. 22. How Do We Fix These Issues?
    23. 23. Recommendations <ul><li>Memory </li></ul><ul><ul><li>Memory is being maxed out. Upgrade to max RAM. </li></ul></ul><ul><li>WEB SERVER- </li></ul><ul><ul><li>Requires 4 GB RAM min. </li></ul></ul><ul><li>SQL 1 </li></ul><ul><ul><li>Requires more than 4 GB. </li></ul></ul><ul><ul><li>Reduce the size of the 12 drives to 40GB from the 72 GB </li></ul></ul><ul><ul><li>More processing power is required. 1.5 GB is not enough power. </li></ul></ul><ul><ul><li>Upgrade to SQL 2005 64 BIT </li></ul></ul><ul><ul><li>Switch from RAID 1 to RAID 0+1 </li></ul></ul><ul><li>SQL 2 </li></ul><ul><ul><li>Same recommendations except drive sizes and SQL are fine. </li></ul></ul><ul><li>SAN </li></ul><ul><ul><li>Reduce the size of the drives from 72GB to 40 GB </li></ul></ul><ul><ul><li>Go 0+1 on all RAID. </li></ul></ul>
    24. 24. Let’s Dig Deeper
    25. 25. OLTP- Online Transaction Processing <ul><li>OLTP work loads are characterized by high volumes of similar small transactions. </li></ul><ul><ul><li>It is important to keep these characteristics in mind as we examine the significance of database design, resource utilization and system performance. </li></ul></ul><ul><ul><li>In this case study, the OLTP was an online system that allowed people to sponsor walkers/runners in MS Society events. </li></ul></ul>
    26. 26. Database Design Issue If: <ul><li>Too many table joins for frequent queries. Overuse of joins in an OLTP application results in longer running queries & wasted system resources. </li></ul><ul><ul><li>Generally, frequent operations requiring 5 or more table joins should be avoided by redesigning the database. </li></ul></ul>
    27. 27. Database Design Issue If: <ul><li>Too many indexes on frequently updated (inclusive of inserts, updates and deletes) tables incur extra index maintenance overhead. </li></ul><ul><ul><li>Generally, OLTP database designs should keep the number of indexes to a functional minimum , again due to the high volumes of similar transactions combined with the cost of index maintenance. </li></ul></ul>
    28. 28. Database Design Issue If: <ul><li>Big IOs such as table and range scans due to missing indexes. </li></ul><ul><ul><li>By definition, OLTP transactions should not require big IOs and should be examined. </li></ul></ul>
    29. 29. Database Design Issue If: <ul><li>Unused indexes incur the cost of index maintenance for inserts, updates, and deletes without benefiting any users. </li></ul><ul><ul><li>Unused indexes should be eliminated. </li></ul></ul><ul><ul><li>Any index that has been used (by select, update or delete operations) will appear in sys.dm_db_index_usage_stats. </li></ul></ul><ul><ul><li>Thus, any defined index not included in this DMV has not been used since the last re-start of SQL Server. </li></ul></ul>
    30. 30. CPU Bottleneck If: <ul><li>Signal waits > 25% of total waits. </li></ul><ul><ul><li>See sys.dm_os_wait_stats for Signal waits and Total waits. </li></ul></ul><ul><ul><li>Signal waits measure the time spent in the runnable queue waiting for CPU. </li></ul></ul><ul><ul><li>High signal waits indicate a CPU bottleneck. </li></ul></ul>
    31. 31. CPU Bottleneck If: <ul><li>Plan re-use < 90% . </li></ul><ul><ul><li>A query plan is used to execute a query. </li></ul></ul><ul><ul><li>Plan re-use is desirable for OLTP workloads because re-creating the same plan (for similar or identical transactions) is a waste of CPU resources. </li></ul></ul><ul><ul><li>Compare SQL Server SQL Statistics: batch requests/sec to SQL compilations/sec. </li></ul></ul><ul><ul><li>Compute plan re-use as follows: Plan re-use = (Batch requests - SQL compilations) / Batch requests. </li></ul></ul><ul><ul><li>Special exception to the plan re-use rule: Zero cost plans will not be cached (not re-used) in SQL 2005 SP2. </li></ul></ul><ul><ul><li>Applications that use zero cost plans will have a lower plan re-use but this is not a performance issue. </li></ul></ul>
    32. 32. CPU Bottleneck If: <ul><li>Parallel wait type cxpacket > 10% of total waits. </li></ul><ul><ul><li>Parallelism sacrifices CPU resources for speed of execution. </li></ul></ul><ul><ul><li>Given the high volumes of OLTP, parallel queries usually reduce OLTP throughput and should be avoided. </li></ul></ul><ul><ul><li>See sys.dm_os_wait_stats for wait statistics. </li></ul></ul>
    33. 33. Memory Bottleneck If: <ul><li>Consistently low average page life expectancy. </li></ul><ul><ul><li>See Average Page Life Expectancy Counter which is in the Perfmon object SQL Server Buffer Manager (this represents is the average number of seconds a page stays in cache). </li></ul></ul><ul><ul><li>For OLTP, an average page life expectancy of 300 is 5 minutes. </li></ul></ul><ul><ul><li>Anything less could indicate memory pressure, missing indexes, or a cache flush. </li></ul></ul>
    34. 34. Memory Bottleneck If: <ul><li>Sudden big drop in page life expectancy. OLTP applications (e.g. small transactions) should have a steady (or slowly increasing) page life expectancy. </li></ul><ul><ul><li>See Perfmon object SQL Server Buffer Manager. </li></ul></ul>
    35. 35. Memory Bottleneck If: <ul><li>Pending memory grants. </li></ul><ul><ul><li>See counter Memory Grants Pending, in the Perfmon object SQL Server Memory Manager. </li></ul></ul><ul><ul><li>Small OLTP transactions should not require a large memory grant. </li></ul></ul>
    36. 36. Memory Bottleneck If: <ul><li>Sudden drops or consistenty low SQL Cache hit ratio. OLTP applications (e.g. small transactions) should have a high cache hit ratio. </li></ul><ul><ul><li>Since OLTP transactions are small, there should not be (1) big drops in SQL Cache hit rates or (2) consistently low cache hit rates < 90%. </li></ul></ul><ul><ul><li>Drops or low cache hit may indicate memory pressure or missing indexes. </li></ul></ul>
    37. 37. IO Bottleneck If: <ul><li>High average disk seconds per read. When the IO subsystem is queued, disk seconds per read increases. </li></ul><ul><ul><li>See Perfmon Logical or Physical disk (disk seconds/read counter). </li></ul></ul><ul><ul><li>Normally it takes 4-8ms to complete a read when there is no IO pressure. </li></ul></ul><ul><ul><li>When the IO subsystem is under pressure due to high IO requests, the average time to complete a read increases, showing the effect of disk queues. </li></ul></ul>
    38. 38. IO Bottleneck If: <ul><li>Periodic higher values for disk seconds/read may be acceptable for many applications. </li></ul><ul><ul><li>For high performance OLTP applications, sophisticated SAN subsystems provide greater IO scalability and resiliency in handling spikes of IO activity. </li></ul></ul><ul><ul><li>Sustained high values for disk seconds/read (>15ms) does indicate a disk bottleneck.udden drops or consistenty low SQL Cache hit ratio. </li></ul></ul><ul><ul><li>OLTP applications (e.g. small transactions) should have a high cache hit ratio. </li></ul></ul><ul><ul><li>Since OLTP transactions are small, there should not be (1) big drops in SQL Cache hit rates or (2) consistently low cache hit rates < 90%. </li></ul></ul><ul><ul><li>Drops or low cache hit may indicate memory pressure or missing indexes. </li></ul></ul>
    39. 39. IO Bottleneck If: <ul><li>High average disk seconds per write. See Perfmon Logical or Physical disk. </li></ul><ul><ul><li>The throughput for high volume OLTP applications is dependent on fast sequential transaction log writes. </li></ul></ul><ul><ul><li>A transaction log write can be as fast as 1ms (or less) for high performance SAN environments. </li></ul></ul><ul><ul><li>For many applications, a periodic spike in average disk seconds per write is acceptable considering the high cost of sophisticated SAN subsystems. </li></ul></ul><ul><ul><li>However, sustained high values for average disk seconds/write is a reliable indicator of a disk bottleneck. </li></ul></ul>
    40. 40. IO Bottleneck If: <ul><li>Big IOs such as table and range scans due to missing indexes. </li></ul><ul><ul><li>Top wait statistics in sys.dm_os_wait_stats are related to IO such as ASYNCH_IO_COMPLETION, IO_COMPLETION, LOGMGR, WRITELOG, or PAGEIOLATCH_x. </li></ul></ul>
    41. 41. Network Bottleneck If: <ul><li>High network latency coupled with an application that incurs many round trips to the database. </li></ul><ul><ul><li>Network bandwidth is used up. </li></ul></ul><ul><ul><li>See counters packets/sec and current bandwidth counters in the network interface object of Performance Monitor. </li></ul></ul><ul><ul><li>For TCP/IP frames actual bandwidth is computed as packets/sec * 1500 * 8 /1000000 Mbps. </li></ul></ul>
    42. 42. SQL Virtualization Hyper-V, is a hypervisor-based technology that is a key feature of Windows Server 2008.It provides scalability and high performance by supporting features like guest multi-processing support and 64-bit guest and host support; reliability and security through its hypervisor architecture; flexibility and manageability by supporting features like quick migration of virtual machines from one physical host to another, and integration with System Center Virtual Machine Manager.
    43. 43. Questions?
    44. 44. Thank You <ul><li>Email: </li></ul><ul><ul><li>[email_address] </li></ul></ul><ul><li>Blog: </li></ul><ul><ul><li>http://mcsegeek.wordpress.com </li></ul></ul>

    ×