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?
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?