homepage Welcome to WebmasterWorld Guest from 54.196.63.93
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Content Management
Forum Library, Charter, Moderators: ergophobe

Content Management Forum

    
Is it not a good idea to store all user profile images in one folder?
NeedExpertHelp

5+ Year Member



 
Msg#: 4194208 posted 11:07 pm on Aug 30, 2010 (gmt 0)

Hi,

In a social networking site where each user has a profile image, is it not a good idea to store all the thousands of profile images in the same folder on your server?

What are the pros and cons?

If the answer is no, then what is a better method?

Thanks!

 

bcc1234

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4194208 posted 11:09 pm on Aug 30, 2010 (gmt 0)

It's not a good idea to store a lot of files of any kind in the same directory.

Most file systems use a list as the main internal structure. So the more files you have in a directory, the more resources it takes to match a file name to an inode.

Instead, use a nested directory structure.

NeedExpertHelp

5+ Year Member



 
Msg#: 4194208 posted 11:19 pm on Aug 30, 2010 (gmt 0)

bcc1234, thanks for your reply.

In the case of profile images on a social networking site, how would you recommend organizing the profile pics and why?

ergophobe

WebmasterWorld Administrator ergophobe us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4194208 posted 12:06 am on Aug 31, 2010 (gmt 0)

If you had all your files using randomaly generated names, allowing a-z0-9, you could just drop them into a directory structure based on the first two characters of the filename like so

./a/b/ab23asdfaw3os49087sd.jpg
./s/d/sdw3sx0d7f30s9derfh3.jpg

And so on. that would give you 1296 directories, with files evenly spread throughout. So with 1,296,000 users, you would only have 1000 files per directory.

There's an interesting read on the web about how Flickr scales to serve billions of images up. Balanced clusters for MySQL servers that hold user information and paths to the actual images which are served up of file servers and which can be addressed directly with the right URL.

[highscalability.com...]

It's from 2007, but it's an interesting read if you think you'll scale to 40 million users and 2 billion images :-)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Content Management
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved