Expert Diagnostic Optimization Series------------------wronged the disk.

Source: Internet
Author: User

Many users are now plagued by slow database problems and are struggling to pay for a professional DBA that is too expensive. Software maintenance personnel on the database is not so deep understanding, so that the problem can not be resolved, or can only be temporarily resolved can not be cured. Developers to solve data problems are basically searching Baidu various methods to try again, may miss the best time to diagnose problems and may try a bunch of methods at last helpless give up.

How to let the trivial of the program maintenance personnel, the fastest way to solve the problem of the database? How to minimize the pain of our programmers ... Drink tea every day to see the news safe through the day? This series of important through the Expert for SQL Server tools to explain the various problems encountered in the database and the root causes of such problems, so that the location of the problem more accurate, the problem-solving ideas clearer!!

The performance of the database is good or bad, for the end-user performance is the click of the operation can respond quickly, then the response to the database is the statement execution time is short enough!

The performance of the operation and maintenance personnel database, the simple may be seen as CPU, memory, disk three major indicators are normal, the previous CPU and memory of the basic diagnosis

Expert Diagnostic Optimization Series------------------is your CPU high? Expert Diagnostic Optimization Series------------------not enough memory?

In this article we will talk about the last giant to see what the disk can see!

No more nonsense, just open the whole-----------------------------------------------------------------------------------------.

    The disk may be for some software OPS personnel, this thing is not my tube! Love how to, slow on the SSD, bad to buy again! But how can you tell the disk is a problem with the disk that is used on the database? Not your database other problems caused? The disk is broken ... The general maintenance staff was crying.

Recommendations for disk Configuration

  The configuration recommendations here are primarily for the disk use of the database, first we define the concept of physical disk and Logical disk.

A physical hard disk is a hardware entity, a hard disk installed in a computer's case, and a logical hard disk is a physical partition that is physically zoned to facilitate access and management of the files inside.

Note: When you feel the pressure on the disk and you want to help share the pressure with another disk, you need to add a physical disk instead of a logical disk.

The main files in SQL Server that are primarily stored on disk and that primarily affect your system are: data files, log files, tempdb data files (the tempdb log can be ignored), many users run these databases or multiple instances on a single server, Well, planning a disk allocation for your existing database is the first lesson!

Planning the benefits of disk allocation: Assuming you have two databases, business operations are busy, and read/write volumes are very stressful on the disk, then you will naturally think of distributing them to different disks, so that each library read/write for its own disk, does not affect each other and the pressure is equivalent to the original 1/ 2, which can increase the response time of the disk operation.

How is the database disk divided? Different systems may not be the same in different environments, here are some simple suggestions:

    1. By file type: Data files, log files, tempdb files, backup files, respectively, on one physical disk (3 physical disks)
    2. By database: Different business databases (high pressure) are placed on one physical disk, one physical disk per tempdb and a backup file.

The two methods above are the basic partitioning method, but according to the system pressure system configuration, there are different situations.

When your database pressure is low, or the disk resource is tight you can do a proper merger. When your database is extremely large and has multiple filegroups, you can also choose to subdivide the filegroups further.

Similar to partitioning tables, different partitions are placed on different disks, and when multiple partition data is required, IO parallelism can be used to improve efficiency.

  

    

How do you differentiate whether your disk is a physical disk or a logic disk?

  

In this example c:h: is the same physical disk, Y:g: Is the same physical disk, Y: And Z: Both are single-partition physical disks. A total of 4 physical disks in this case

In this example, each is a separate physical disk

Note: Disk information can be viewed through System information (running-MSINFO32) or by means of performance counters and so on.

Here is an example of a file partition: (example using the above c:d:e:f:j is a separate physical disk)

   

Tempdb on the F-drive

   

The data file (. mdf) is placed on the D drive, and the log file (. ldf) is placed on the E-drive

Diagnosis and analysis of disk pressure

Disk stress analysis, mainly using the following performance counters (for individual physical disks, each physical disk will have a set):

    1. Avg. Disk Read Queue Length read queues (the smaller the better, the ideal value below 2, the higher the queue, the longer the response time of an operation)
    2. Avg. Disk Write Queue Length write queues (the smaller the better, the ideal value below 2, the higher the queue, the longer the response time of an operation)
    3. Avg. Disk Sec/read
    4. Avg. Disk Sec/write
    5. Disk Read bytes/sec
    6. Disk Write bytes/sec

    Note: The General Judgment system disk pressure, through the reading and writing queue can be judged, the following 4 is mainly used for the disk whether its own performance problems, this article does not introduce.

What are the first conditions that can cause stress to the disk?

    1. Insufficient memory to cause frequent and disk interaction ( typically primary )
    2. Often there is a lot of cold data that needs to be read from disk, or often there is a large amount of dirty page write once (checkpoint trigger)
    3. Disk read and write speed, unable to meet business needs

   Why is insufficient memory causing a large disk pressure? 

The previous article describes how the memory of the three counters are linked?

Page life expectancy the number of seconds that pages in the cache are not being used, if low indicates memory pressure

Page reads/sec The data to be read does not need to be physically read in memory

Lazy writes/sec memory pressure when batch flushes the aging buffer

   Read and write counters for disk: AVG. Disk Write Queue length and Avg. Disk Read Queue length and memory counters are also linked to a large extent!

When an operation requires a large amount of data to be read and the data page is not in the cache--"There is a large amount of reading cold data from disk into the cache (page reads/sec raised,Avg. Disk Read Queue length raised )--" When the cache has significant pressure, the lazy writes/sec will trigger (thelazy writes/sec to Rise ), a large number of the aging of the data or cache plan to brush out the cache--"It is clear cache (dirty pages need to write to disk Avg. Disk Write Queue Length), the page life cycle will drop (page lifetime expectancy)

——》

Borrowed the previous Expert diagnostic optimization series------------------not enough memory? Three hours a memory example, let's see how the disk behaves

   

   

   

This is a regular fluctuation, memory pressure is very regular, memory pressure but more introduction please refer to the previous article. Let's see what the counter of the disk corresponds to the point in time. Can you think of it?

   

   

    Does it have a strong rule? This example shows the disk pressure and memory linkage, also shows that when you see the disk queue is very high, do not easily locate the problem of the disk, first look at the current system memory is what the state of it.

   With the last second, an example of a critically low memory:

   

  

   

   

Let's take a look at the pressure of such a large memory, what is the state of the disk, I think I have not said much.

   

   

   High-energy warning: The queue is highly likely, not so intuitive to explain what, let's look at the response time under this high queue. Each time you interact with a disk, you have more than 1 seconds of disk response time (normal milliseconds), so what is the effect of multiple interactions of a statement?

   

  

----------------------------------------------------------------------------------

Now we understand that the root cause of high system disk queue is due to insufficient memory, then we put aside the memory pressure , we encounter the above situation how to alleviate the disk pressure???

That is the earlier mention of using multiple disks to share this pressure or choose faster.

Take a look at the disk and database file distribution of this system

   

You can see that this server is configured with only one physical disk

  

Database 1

   

Database 2

   

Tempdb

   

2 large, business-critical databases, data files, log files, and system tempdb are all on the same disk!

   If there are other physical disks that can share the pressure, the read-write queue will be reduced, and the read-write response time will be significantly shortened, but we cannot ignore the root cause is the memory of the great pressure !

The best optimization effect, of course, is to do memory optimization (see the previous Expert diagnostic optimization series------------------not enough memory? Also, according to best practice, distribute the files across multiple disks to share the pressure.

-----------------------------------------------------------------------------------------------------

Summary: Now hardware costs are getting lower, many users are using SSD or advanced storage, etc., directly to improve the hardware system to optimize the way.

However, this article mainly introduces the main cause of disk pressure is insufficient memory, memory is not enough to write too bad, or obviously lack of index.

Do not let a very simple tuning to solve the problem, upgrade to spend expensive to change hardware.

There is no denying that improving the hardware will certainly happen, but it is even more important to find out the real reason for the system.

     

   

----------------------------------------------------------------------------------------------------

Note: This article is original, welcome reprint, please in the article page obvious location give this article link!
If you think this article is not bad please click on the lower right corner of the recommendation , thank you very much!

Quote Gaodashia in a sentence: "Deny SQL Server back pot, start with me!"

Expert Diagnostic Optimization Series------------------wronged the disk.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.