3

I'm building a service where I'll need to store a ton of files on a filesystem. I've heard in the past that it's better to separate up files by folder when dealing with large amounts of files. Is this really accurate for modern Linux filesystems such as ext3, ext4, and btrfs? If so, how much should I divide up files? Should I keep 1000 files to a folder?

The current setup I have divides them up into hundreds, thousands, tens of thousands, and hundreds of thousands like so:

stream id: 123456
1/2/3/4/123456.file

stream id: 654321
6/5/4/3/654321.file

stream id: 5
0/0/0/0/5.file

Does this make sense for my application?

Naftuli Kay
  • 1,648
  • 6
  • 22
  • 43
  • 1
    Just because they're all "modern", doesn't mean they all perform the same in all circumstances. Please be more specific in future. – womble Aug 12 '11 at 01:15

1 Answers1

5

You should also consider the amount folders you are creating.

In the related question the general rule seems to be up to 20k files per directory for performance reasons:
Maximum number of files in one ext3 directory while still getting acceptable performance?

Leah
  • 168
  • 1
  • 4
  • 10