Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many files in a directory is too many (on Windows and Linux)? [duplicate]

Tags:

Possible Duplicate:
How many files in a directory is too many?

I was told that putting too many files in a directory can cause performance problems in Linux, and Windows. Is this true? And if so, what's the best way to avoid this?

like image 940
Rhubarb Avatar asked Jun 08 '10 03:06

Rhubarb


People also ask

How many files is too many in a directory?

My general rule of thumb is that more than about 20,000 files in a directory is not a good idea. Most modern filesystems do ok with that many files. Once you hit 32k files in a directory some filesystems such as ext3 will start having serious performance issues.

How many files is too many Linux?

By default, this is 1024.

What is the maximum number of files in a Windows folder?

Maximum file size: 256 terabytes. Maximum number of files on disk: 4,294,967,295. Maximum number of files in a single folder: 4,294,967,295.

Is there a maximum number of files in a folder Linux?

Maximum number of files: 232 - 1 (4,294,967,295) Maximum number of files per directory: unlimited. Maximum file size: 244 - 1 bytes (16 TiB - 1) Maximum volume size: 248 - 1 bytes (256 TiB - 1)


1 Answers

According to this Microsoft article, the lookup time of a directory increases proportional to the square of the number of entries. (Although that was a bug against NT 3.5.)

A similar question was asked on the Old Joel on Software Forum. One answer was that performance seems to drop between 1000 and 3000 files, and one poster hit a hard limit at 18000 files. Still another post claims that 300,000 files are possible but search times decrease rapidly as all the 8.3 filenames are used up.

To avoid large directories, create one, two or more levels of subdirectories and hash the files into those. The simplest kind of hash uses the letters of the filename. So a file starting abc0001.txt would be placed as a\b\c\abc0001.txt, assuming you chose 3 levels of nesting. 3 is probably overkill - using two characters per directory reduces the number of nesting levels. e.g. ab\abc0001.txt. You will only need to go to two levels of nesting if you anticipate that any directory will have vastly more than ca. 3000 files.

like image 72
mdma Avatar answered Oct 03 '22 02:10

mdma