0

Possible Duplicate:
Storing a million images in the filesystem

I am designing a website which will potentially have millions of images. Whats the best way to arrange them..All of the images are uploaded by some users. I am thinking of creating a folder structure with their user id and put the image in it..Does it make any server issue..like maximum number of folders or server performance..Please let me know if you can think of some best architecture...?

Another way I am thinking was: create folder from a to z and inside I will create user's folder and keep the images

Thank you for your valuable suggestion

I will use Linux file system..php to upload files, gd2 to resize images.

  • Are you expecting millions of users uploading a few images or a few users uploading millions of images? Are you wanting to keep the filename the users upload with? Could these result in duplicate filenames? Could you offload this work to Amazon S3 or Rackspace Cloud Files? – WheresAlice Aug 02 '10 at 22:45

1 Answers1

4

Honestly, the way you arrange them should depend on what exactly you are doing with the pictures. Do you want them organized by user, or do you want them in a pool. How are you presenting the images. Also, how are you going to name the images? You could certainly do what you are asking about, though I wonder about the necessity of the extra level of a-z folders. That seems like a bit of unnecessary depth. You could also honestly put them all in one folder together and use UUIDs to name the pictures to ensure you don't have name collisions. Depending on how you want to manage them, you'll probably want to keep a database of the pictures to allow ease of access. If you provide more details on what you are wanting to do, we can provide more useful suggestions.

Tristan
  • 186
  • 3
  • Most filesystems will have trouble with 1M files in one directory. 1000 files should be fine, 10k is already pushing it with some. Other than that, it's an organization issue, and the answer is bound to be extremely situation-specific. – Gilles 'SO- stop being evil' Aug 02 '10 at 22:06
  • Ext3/4 and XFS shouldn't have any trouble with it. Theoretically, Ext2 can handle 10^20 files in a directory – Tristan Aug 02 '10 at 22:17
  • You can't have more files than inodes, and you'll hit that limit a long time before you hit 10^20. Ext2 performance is horrible when you've got thousands of files in a directory. Ext3 has the dir_index option which will store directories in trees for significantly improved performance. – gbroiles Aug 03 '10 at 05:34