We're building a product that is likely to generate very large XFS volumes, and I'm trying to discover the scaling bottlenecks we're likely to run into given the architecture.
As we manipulate files they get placed into directories on the XFS volumes. Due to the number of files we handle, the file-count is definitely in the tens of millions and will likely get into the hundreds of millions before too long after release. We know this because our current product behaves this way, so it is reasonable to expect our next one to do similarly.
Therefore, correct early engineering is in order.
This week the files are based on the following rough layout:
$ProjectID/$SubProjectID/[md5sum chunked into groups of 4]/file
Which gives directories that look kind of like:
The reason for chunking the md5sum is to avoid the "big pile of files/directories in one directory" problem. Due to the md5sum chunking it means that 1 file causes 8 directories to be created. This has pretty clear inode impacts, but I'm unclear on what those impacts will be for XFS once we get up to scale.
What are the impacts?
This is with kernel 2.6.32 by the way, CentOS 6.2 at the moment (this can change if needed).
In testing I've created the xfs volume with defaults, and am not using any mount-options. This is to smoke out problems early.
noatime is something of a no-brainer as we don't need it. Overall XFS tuning is another problem I need to tackle, but right now I'm concerned about the metadata multiplier effect we've engineered in right now.
I already know what a better solution will be, I just don't know if I have a case to push for the change.
Since md5sums are significantly unique in the first digits, and individual sub-projects rarely exceed 5 million files, it seems to me that we only need the first two chunks. Which would yield layouts like:
A completely full first and second levels would have 216 first level directories and 216 second level directories in each first level directory, for a total of 232 directories on the volume.
The hypothetical 5 million file sub-project would therefore have 216 first level directories, roughly 76 (+/- 2) second tier directories in each, and one or two third tier directories in each second tier directory.
This layout is a lot more metadata efficient. I just don't know if is worth the effort to change how things are going right now.