Saturday, November 24, 2007

Optimizing NTFS Performance

If you are writing any web services that store large files on an NTFS volume, this section is very useful - full article here.

Optimizing NTFS Performance

NTFS performance is affected by many factors, such as cluster size, fragmentation level, and the use of programs such as antivirus software. In addition, NTFS features such as compression and Indexing Service can also affect performance. Optimize the performance of NTFS volumes by using the following guidelines.
Determine Cluster Size

Before you format an NTFS volume, evaluate the types of files to be stored on the volume to determine whether to use the default cluster size. Some important questions to answer include:

* Are the files typically the same size?
* Are the files smaller than the default cluster size?
* Do the files remain the same size or grow larger?

If the files are typically smaller than the default cluster size (for example, 4 KB) and do not increase, use the default cluster size to reduce wasted disk space. However, smaller clusters can increase fragmentation, especially when files grow to fill more than one cluster. Therefore, adjust the cluster size accordingly when you format the volume. If the files you store tend to be large or increase in size, use 16-KB or 32-KB clusters instead of the default 4-KB cluster size.

Note Compression is supported only on volumes that use 4-KB or smaller clusters.

Cluster size is also an issue for volumes that were converted from FAT to NTFS in Windows 2000 or earlier because the default cluster size for converted volumes is 512 bytes, and the MFT was most likely fragmented during the conversion. For optimum performance, back up the data on the volume, reformat the volume, specify the appropriate cluster size, and then restore the data.

For more information about choosing a cluster size, see “Cluster Size” earlier in this chapter.
Use Short File Names

Every time you create a file with a long file name, NTFS creates a second file entry that has a similar 8.3 short file name. A file with an 8.3 short file name has a file name containing 1 to 8 characters and a file name extension containing 1 to 3 characters. The file name and file name extension are separated by a period.

If you have a large number of files (300,000 or more) in a folder, and the files have long file names with the same initial characters, the time required to create the files increases. The increase occurs because NTFS bases the short file name on the first six characters of the long file name. In folders with more than 300,000 files, the short file names start to conflict after NTFS uses all the 8.3 names that are similar to the long file names. Repeated conflicts between a generated short file name and existing short file names cause NTFS to regenerate the short file name from 6 to 8 times.

To reduce the time required to create files, use the fsutil behavior set disable8dot3 command to disable the creation of 8.3 short file names. (You must restart your computer for this setting to take effect.) For more information about disabling 8.3 short file names, see “MS-DOS-Readable File Names on NTFS Volumes” later in this chapter.

If you want NTFS to generate 8.3 names, improve performance by using a naming scheme in which long file names differ at the beginning of the name instead of at the end.

For more information about short file names, see “File Names in Windows XP Professional” later in this chapter.
Determine Folder Structure

NTFS supports volumes with large numbers of files and folders, so create a folder structure that works best for your organization. Some guidelines to consider when designing a folder structure include:

* Avoid putting a large number of files into a folder if you use programs that create, delete, open, or close files quickly or frequently. The better solution is to logically separate the files into folders to distribute the workload on multiple folders at the same time.

* If there is no way to logically separate the files into folders, put all the files into one folder and then disable 8.3 file name generation. If you must use 8.3 names, use a file-naming scheme that ensures that the first six characters are unique.

Warning The time required to run Chkdsk.exe increases with larger folders. For more information about determining how long Chkdsk takes to complete, see Chapter 28, “Troubleshooting Disks and File Systems.”

No comments: