VIII. IO optimization (7) Reduce IO Competition

Source: Internet
Author: User
I. Automatic growth and automatic contraction 1. Automatic growth by default, the size of database files can be automatically increased as needed. This can increase the file size until the disk is full. (1) Automatic growth is not allowed if production

I. Automatic growth and automatic contraction 1. Automatic growth by default, the size of database files can be automatically increased as needed. This can increase the file size until the disk is full. (1) Automatic growth is not allowed if production

I. Automatic growth and automatic contraction

1. Automatic Growth

By default, the size of database files can be automatically increased as needed. This can increase the file size until the disk is full.

(1) Automatic growth not allowed

If the production environment does not allow auto-Growth of applications that may occur during the operation to time out, space should be pre-allocated for the expected workload.

If Automatic growth is not allowed and the database space is full, SQL Server Reports "database full" and rejects New Data Writing.


(2) Allow automatic Growth

It is generally recommended that the database be set to auto-increment. In case of exceptions, this setting will be used to increase the disk space of database files. That is to say, automatic growth is an insurance. When "database full" is used, it automatically increases the available space for the database.


2. Auto-increment settings

Set the file increment to a reasonable size to avoid the database file increment being too small. If the file increment is too small compared with the amount of data written to the database, the database may need to expand continuously. This will affect performance.

We recommend that you follow the following general principles when setting FILEGROWTH increments for database files.

(1) When the database file size is 0 to 100 MB, the increment is 10 MB.

(2) When the database file size is 100 to 200 MB, the increment is 20 MB.

(3) When the database file size exceeds 200 MB, the increment is 10%. This increment may have to adjust this percentage based on the speed of the I/O subsystem where the database file is located.


3. Initialization

To avoid potential latencies, we recommend that you limit the automatic growth operation to about two minutes. For example, if the I/O subsystem initializes a file at a speed of 50 MB per second, the FILEGROWTH increment should be set to a maximum of 6 GB regardless of the size of the database file.

You can use the instant file initialization function to Improve the Performance (v = SQL .105). aspx


4. automatic contraction

SQL Server does not continuously test databases that have reached the configured threshold for automatic contraction. Instead, it looks for available databases and finds the first database configured to automatically contract. It will check the database and contract it as needed. Then, it will wait a few minutes and then check the next database configured to automatically contract.

In other words, SQL Server does not check and contract all databases at the same time. It processes each database cyclically to make the load time staggered. Therefore, it may take several hours to scale down the database from the threshold to the actual scale-down, depending on the number of databases configured for automatic scale-down on a specific SQL Server instance.


5. Suggestions

The automatic growth of databases may cause the following problems:

(1) Controllable Growth

The database grows automatically, usually because a large amount of data is written, which often occurs during business peak hours. Therefore, automatic growth will often drag down the database performance during business peaks. If the growth is large, or there are other factors that lead to a longer time, the query in which you open the transaction may fail due to a timeout error.

For managed production systems, you must regard automatic growth only as accidental growth. Do not use automatic growth to manage daily data and log growth.

We recommend that you manually increase the database space on a regular basis (weekly or monthly) during off-peak hours. As to how much space is needed, we should monitor the size of the database and estimate its growth trend.


(2) monitor available disk space

When the automatic growth setting is used, the size of the database after growth cannot exceed the available disk space on the drive for the defined file. Therefore, if you rely on the auto-increment function to determine the size of your database, you must check the available hard disk space. Therefore, changes in disk space should be monitored to predict disk space usage in advance.


(3) Disable auto-shrinking

Generally, automatic contraction is not recommended.

If you use both the auto-increment and auto-increment options, unnecessary overhead may occur. Make sure that the threshold value for triggering the growth and contraction operations does not cause frequent size adjustments. For example, you may run such a transaction, which causes the transaction log to increase by 100 MB at the time of submission. The transaction log is reduced by 100 MB within a period of time after the automatic contraction starts. Then, you run the same transaction, and the transaction log increases by 100 MB again. In this example, you cause unnecessary overhead and may cause Log File fragments, both of which may have a negative impact on performance.



Ii. File Distribution

In SQL Server, disk I/O competition mainly occurs in the following content. We recommend that you store these files on different physical disks.

(1) user database data files (mdf and ndf files)

(2) Transaction Log File (ldf file) of the user database)

(3) data files and log files of the tempdb Database

(4) bak and trn files generated during Backup.

(5) Windows system events and paging files.



Iii. Disk Subsystem

1. array card

Generally, the Disk uses the following RAID (Redundant Array of Independent Disk, an Independent Redundant Disk Array ).

(1) RAID 0

That is, Data Stripping (Data sharding technology ). The data on the entire Logical Disk is distributed across multiple physical disks, and can be read/written in parallel to provide the fastest speed, but there is no redundancy capability. At least two disks are required.

RAID 0 can be used to obtain a larger capacity of a single logical disk, and a higher access speed can be obtained by simultaneously reading multiple disks. RAID 0 first considers the disk speed and capacity, ignoring the security. As long as one of the Disks has a problem, the data in the entire array will not be guaranteed.


(2) RAID 1

That is, mirroring (Mirror), that is, data redundancy. In the entire image process, only half of the disk capacity is valid (the other half is used to store the same data ). Compared with RAID 0, RAID 1 first considers security, halving the capacity, and changing the speed.


(3) RAID 5

RAID 5 is used to cut the data validation generated by each disk into blocks and store them in each disk that forms an array, this relieves the bottleneck during data storage verification. However, data splitting and storage control are all subject to a high speed. This means that RAID 5 slows down data writing.


(4) RAID 10

To achieve high speed and security, RAID 10 (or RAID 0 + 1) can be simply split into a RAID 0 array consisting of multiple disks for mirroring. This combination enables fast reading and writing. But the capacity is halved.


2. Suggestions

(1) tempdb

Tempdb databases have high performance requirements, but have low data security requirements. We recommend that you place the tempdb database in the fast I/O subsystem. If you have many directly connected disks, use RAID 0.


(2) Data Files (mdf and ndf files)

Such files require performance and security. RAID 10 is recommended. If the hardware budget is very tight, the RAID 5 should also work together.


(3) Transaction Log File (ldf file)

Transaction log files are written sequentially. Therefore, they do not have high performance requirements and only require security. RAID 1 is recommended.



Conclusion:

Avoid the competition of various disk I/O and avoid unnecessary performance overhead.


This article is from the "MSSQL we have Chased Together" blog. For more information, contact the author!

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.