SQL Database Management - Chapter IV use Performance Monitor to monitor database windows

SQL Database Management - Chapter IV use Performance Monitor to monitor database windows

4.1 Monitoring Overview

 Target monitoring database is to understand the situation inside SQL database occurs, concurrent SQL database, user connections, server resources (CPU, memory, IO) efficiency, the application waits for the situation. Capture these cases make informed DBA door system up and running.

4.2 to establish a baseline

 After the on-line system, concurrent user connections, server resources (CPU, memory, IO) efficiency, the application waits for the situation to establish a baseline, or update the system after a long run can make a comparison based on the reference, a problem solved in time.

4.3 identify bottlenecks

Possible bottlenecks

Impact of the database

Memory Usage

Insufficient memory allocation or by the Microsoft SQL Server  memory usage of inadequate results in performance degradation.  Data must be read from disk rather than reading directly from the data cache.  When the required page, in the Microsoft Windows operating system to perform a large number of disk paging operation by exchanging data.

CPU usage

Long-term high CPU usage may indicate that  Transact-SQL  queries or need to optimize CPU needs to be upgraded.

Disk input / output (I / O)

Transact-SQL  can be optimized to reduce unnecessary query the I / O (e.g., using an index).

Concurrent user connections

There may be too many users simultaneously access the server, causing performance degradation. Concurrent operation Batch cause performance degradation.

Blocking locks

Application design may result in unreasonable prejudice or lock concurrency, resulting in longer response times and lower transaction throughput speeds.

 

4.4 Monitoring database user connections, number of concurrent.

    SQL database to set the maximum number of connections select @@ max_connections default 32767

    Set SQL database maximum number of connections (usually not provided) exec sp_configure 'user connections', 100

SELECT @@ CONNECTIONS Views database since the last start of the connection.

The number of concurrent SQL database is the number of batches per second.

Can use windows performance counter view the user comes to the number of concurrent connections

4.4.1 SQLServer: SQL Statistics: Batch Requests / Sec (SqlServer Statistics: Batch Requests / sec). The user determines the size of the system load.

  Batch requests / sec means that SQL Server is the number of receivers per second batch. This counter can see our server processing speed. The larger the number, the greater show our database query processing throughput. Like many counters as there is no single number that can explain the server is too busy. Today, more and more powerful server, so it can not stop a moment to process more batch requests. Over time, this counter should be collected to determine what our server environment baseline value yes.

4.4.2 SQLServer: General Statistics: User Connections (SqlServer: General Statistics: Users connected)

  Counter is the number of users connected to the same time the user connects to the server. We need to look at the baseline number of user connections, the number of users at different times are different, and there is a high and low range. If the value of this counter drops, and the load on the system is the same, then there could be a bottleneck, resulting in normal load our server can not be handled, the need to check it out. Of course, also pay attention to the counter value decline may be less because of the connection it does.

4.4.3 SQL Server Databases: Transactions / sec : is the number of database transactions started per second. The user determines the size of the system load.

4.5 Monitoring database CPU

CPU is the most important server resources. In the database server, CPU usage should always be monitored in order to SQLServer has been at its best.

 

4.5.1 Processor:% Processor Time  to reach 75% of the need to pay attention.

 

An effective method to determine whether to use the CPU usage of the system monitor Processor:% Processor Time counter. The counter monitors CPU execution time of a non-idle thread used. For 80% to 90% of the state may indicate a need to upgrade the CPU or add more processors.

 

4.5.2 System: Processor Queue Length reaches the number of processors + 1 need attention

It corresponds to the number of threads waiting for processor time. When the number of processor cycles threads of a process require more than the number of cycles available, it will produce a processor bottleneck. If there are many processes in contention for processor time, you may need to install a faster processor. If you are using a multiprocessor system, you can add a processor.

If the processor queue length exceeds the total number + 1 has been available on the server processor, the processor may indicate blockage.

 

4.6 Monitoring database memory (need to understand)

Monitor memory usage. Memory Monitoring Server is a very important thing, there are many conditions can cause memory consumption. So should regularly check-ups.

1 Memory: Available Mbytes: remaining available memory

2 Memory: Pages / sec: is understood to read data from the hard disk memory. Only on the server running sqlserver, that this ideal range of indicators should be between 0-20, and occasionally more than 20 words have little effect, if this value frequently exceeds 20, it means that your server may need to add a memory.

3 SQL Server: Buffer Manager: Buffer Cache Hit Ratio: cache hit rate, without the need to read to find the percentage of pages (physical I / O) from the disk in the buffer cache. Determining whether sufficient memory is available, the best guarantee of more than 95%. 95% or higher hit rate is satisfactory. Add more memory until the value is always greater than 95%. Values ​​greater than 95% of the data indicating all cached data satisfies the request more than 95% of the requests.

4SQL Server: Buffer Manager: Page life expectancy, represents the number of seconds of data pages reside within the memory. Microsoft recommends a minimum of 300 seconds. If less than 300 seconds, often one example, means that the data retention time is less than 5 minutes to be moved out of memory.

4.7 Monitoring database IO

Microsoft SQL Server performance depends largely on the I / O subsystem (IOS). IOS delay may lead to many performance problems.

4.7.1 Primary Main

PhysicalDisk:. Avg Disk sec / Write Average Disk sec / Write

PhysicalDisk:. Avg Disk sec / Read Avg. Disk sec / Read

Database log no more than 5ms

OLTP database no more than 10MS

OLAP no more than 25MS

Less than 10 ms - very good      棒       

Between 10 - 20 ms – good       好

Between 20 - 50 ms - slow, needs attention slow note

Greater than 50 ms - Serious I / O bottleneck serious IO bottleneck

 

4.7.2 Secondary Secondary

PhysicalDisk:. Avg Disk Queue Length Disk Queue server storing operation is issued is the number of requests waiting to be processed is stored. For example, an application issues a read request, but was the target disk is processing other tasks. Then the new read request is placed in the disk queue. This time the value of the disk queue is 1. If this value is greater than 2 , the problem by the disk array performance.

PhysicalDisk:. Avg Disk Queue Length If this value is particularly large, you can monitor these three parameters, Avg Disk Queue length the Read. , Avg Disk Queue the Write length. , Current Disk Queue the Length . 

For example the 4 compositions drives into RAID5

Avg. Disk Queue Length = 12 per hard disk is 12/4 = 3 it is clear that the performance problems.

PhysicalDisk: Disk Bytes / sec memory bandwidth is used to determine whether enough.

PhysicalDisk: Disk Transfers / sec to determine whether enough IOPS.

 

First, to monitor the main counter, if the counter is not the main problem, it does not counter the secondary monitor.

Disk transfer / sec by the disk read / write disks and sec / sec composition. You can use these counters to determine whether the drive does not have enough support disk. When using these counters, you may need to adjust the value of the type of RAID has been implemented. To determine the value to use, use the following formula:

Raid 0 - each disk I / O = (read + write) / number of disk

Raid 1 - each disk I / O = [read + (2 * Write)] / 2

Raid 5 - each disk I / O = [read + (4 * write)] / number of disks

Raid 10 - each disk I / O = [read + (2 * Write)] / number of disks

For example, if the maximum disk transfer / sec to 1800, it may be determined that the drive RAID group must have at least 10 15k RPM disks. Typically, 15k RPM disk 180 can be performed approximately I / O request (IOPS) per second. 180 * 10 = 1800. For higher values, you may need more than 10 disks. Because achieve a single hard disk IOPS80% there will be a performance problem, it requires a minimum of 12 more than a hard disk.

If serious performance problems, consider the following solutions.

  1. Use faster disks
  2. Increase the number of hard disk
  3. A faster RAID type, such as RAID 10.
  4. Data files and log files on different disks in the array.

 

Disk Bytes / sec is high, Avg. Disk sec / the Write , Disk sec / the Read all instructions are very hard problem, a lot of read data per second, high average literacy explanation, perhaps hard drive performance is very good.   Sec Disk / the Write , Disk sec / the Read high, Disk Bytes / sec is very low note is the hard drive problem. To see all the parameters together.

4.8 Monitoring and obstruction database lock

4.8.1 SQLServer: Locks: Lock Waits / Sec: (SqlServer : the locks: lock waiting / sec: All) This value is preferably 0.

  In order to manage the SQL Server when concurrent users on the system, SQL Server locks resources need to frequent, sometimes long and sometimes short. Lock Wait / s per second is a pointer system waits for the requested number of resources is just locked. Ideally we do not want to wait any locks required, therefore, to keep this counter to zero or close to zero.

  

4.8.2 SQLServer: Locks: Number of Deadlocks / sec: (SqlServer : the lock: cause deadlock lock requests per second) This value is preferably 0.

  Means causes a deadlock lock requests per second. Deadlock for scalability of the application is very harmful and can lead to poor user experience. The counter must be 0, preferably 0 also.

 

4.8.3 SQLServer: General Statistic: Processes Block (SqlServer: General Statistics: Process blocked)

  Process to block a time counter is the number of blocked processes. When a resource because the application process is not released, the process was blocked, while others rely on the same resource process can not move forward, leading to more and more blocked processes, to solve this problem only way until its resources are released. Ideally we do not want to see any obstruction of the process, when the process is blocked should be a thorough investigation.

4.9 Monitoring database performance log

SQL Server: Databases Counter

4.9.1 SQL Server :Databases :Log Flushes/sec  

The number of times per second on the SQL Server database to do the log written. The number of logs per second refresh

  

4.9.2 SQL Server :Databases :Log Bytes Flushed/sec  

SQL Server per second done on this database log written by the amount of Bytes.

  

4.9.3 SQL Server :Databases :Log Flush Wait Time

  Operation wait time once because the disk response time to encounter written to the log. This will lead to the front of the waiting transaction can not be submitted, it will seriously affect the performance of SQL Server. Normal SQL Server, the total waiting time to refresh the log (ms) This value should be most of the time are zero.

  

4.9.4 SQL Server :Databases :Log Flush Waits/sec

  In the transaction commits per second, the number of transactions have been waiting for log write completed. Ideally, the log is written should be done immediately, no need to wait. If there are other places, ah, you need to check the log file storage disk performance. Wait for the log number of submissions per second refresh

Published 37 original articles · won praise 0 · Views 2422

Guess you like

Origin blog.csdn.net/syjhct/article/details/86321184