title: Amazon AWS S3 file naming strategy for performance
body: <p>I am currently utilizing the following naming scheme:</p>
  
  <pre><code>/#{bucket_name}/#{customer_name}/fi/le/na/filename.jpg
  </code></pre>
  
  <p>So an image for a file named <code>dsca007.jpg</code> for customer <code>bent</code> would be stored here:</p>
  
  <pre><code>/images/bent/ds/ca/00/dsca007.jpg
  </code></pre>
  
  <p>But I can understand that S3 wants a different form like this:</p>
  
  <p><img src="https://i.stack.imgur.com/KhUk6.png" alt="enter image description here"></p>
  
  <p>Source: <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/request-rate-perf-considerations.html" rel="noreferrer">http://docs.aws.amazon.com/AmazonS3/latest/dev/request-rate-perf-considerations.html</a></p>
  
  <p>Source: <a href="https://www.youtube.com/watch?v=uXHw0Xae2ww#t=535" rel="noreferrer">https://www.youtube.com/watch?v=uXHw0Xae2ww#t=535</a></p>
  
  <p>I understand that they want me to change my naming scheme to something like:</p>
  
  <pre><code>/#{bucket_name}/fi/le/na/#{customer_name})filename.jpg
  </code></pre>
  
  <p>But then he shows this slide in the youtube video:</p>
  
  <p><img src="https://i.stack.imgur.com/ozLYS.png" alt="enter image description here"></p>
  
  <p>Does that mean that my first approach was fine?</p>
  
  <p>I really liked the first structure better because I was able to get a list of files owned by one customer, is there a way to list all files under a customer with the last mentioned naming scheme?</p>
  
  <p>It was also quite easy to figure out how much storage each customer was using by running this command:</p>
  
  <pre><code>s3cmd du s3://images/#{customer_name}
  </code></pre>
  
  <p>How can I do that with the new naming scheme?</p>