How do you save millions of images on your server?

Possible duplicate:
Saving a large number of images

Hello,

I want to be able to scale millions of user profile photos on my LAMP server using PHP.

Currently, I save all the images in one folder, which is a big no-no, so I want to decompose them into many folders and subfolders (e.g. aa / bb / etc ...).

What is the best and most effective way to do this, especially if I don't want to call the database to get the file name / path for this user profile?

I'm thinking of making a username hash and using the first 4 letters of this hash to generate / find the path for this user profile profile, so I would not need anything accessible from the database since I will always have a username. So, for example, if the first 4 characters of the user's username hash were “aabb”, I would save this pic user profile as aa / bb / username / profile.jpg, which theoretically allows me to scale millions of users without adding anything to the database, evenly distributing all the images throughout the aa / bb / folder structure.

Any ideas / input?

Thank!

+3
source share
1 answer

Depending on how your users are organized.

  • , . , 0xx/007.png, 8xx/824.png 547xx/54723.png. 100 , 100 .

  • , , . , , . , ma/master_of_desaster.png, ki/king_cool.png so/some_other_infantile_name.png

  • - . (, ), , , . CRC32. [CRC32sum]/[USER_ID].png

+1

All Articles