SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: User Folders

  1. #1
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    User Folders

    I have a site that allows users to upload pictures. What I am doing is storing their images in a folder(paths in mysql) on the system that corresponds to their user id. What I'm wondering is, if I have 5000 or 10000 users, will having 5000 or 10000 user directories in one directory slow down the app? I was thinking that I would just group the users in chunks of 500 or a 1000. Is this necessary, or just put them all in the same directory?

  2. #2
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Regina, SK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm, good question. This used to be an issue, but I think most modern os's can handle it. I know there were problems going over a certain number of files/dirs for certain filesystems, FAT jumps to mind real quick. One way I've seen to avoid this would be the use of subdirectories. If you have userids as your index, you could use the first one or two chars as a sub directory, then their full userid as a directory under that

    (users aaabcd aabbcd aacbcd abcde abcdf)
    /users/aa/aaabcd
    /users/aa/aabbcd
    /users/aa/aacbcd
    /users/ab/abcde
    /users/ab/abcdf

    If you are expecting thousands of directories, I woudl definitely say go to a more scaled approach like I mentioned. Accessing each file or directory may not be too bad, but having to do any type of search through a directory containing thousand of entries would get taxking.
    Reduce or eliminate spam on your sites without CAPTHCAs
    - maybe it is possible: http://formantispam.thekerrs.ca/

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's sort of what I thought nos. The way it is written now is that I take the userid and divide by 500. I take the floor of the integer that results and that becomes the subdir the user dir goes in.

    (users: 1, 35, 499, 501)
    /users/0/1/
    /users/0/35/
    /users/0/499/
    /users/1/501/

    edit: should this not have stayed in the php application design forum?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •