title: Storing & accessing up to 10 million files in Linux
body: <p>I'm writing an app that needs to store lots of files up to approx 10 million.</p>
  
  <p>They are presently named with a UUID and are going to be around 4MB each but always the same size.  Reading and writing from/to these files will always be sequential.</p>
  
  <p>2 main questions I am seeking answers for:</p>
  
  <p>1) Which filesystem would be best for this. XFS or ext4?
  2) Would it be necessary to store the files beneath subdirectories in order to reduce the numbers of files within a single directory?</p>
  
  <p>For question 2, I note that people have attempted to discover the XFS limit for number of files you can store in a single directory and haven't found the limit which exceeds millions. They noted no performance problems.  What about under ext4?</p>
  
  <p>Googling around with people doing similar things, some people suggested storing the inode number as a link to the file instead of the filename for performance (this is in a database index.  which I'm also using).  However, I don't see a usable API for opening the file by inode number.  That seemed to be more of a suggestion for improving performance under ext3 which I am not intending to use by the way.</p>
  
  <p>What are the ext4 and XFS limits?  What performance benefits are there from one over the other and could you see a reason to use ext4 over XFS in my case?</p>