locked
User Directory Structure RRS feed

  • Question

  • User777071773 posted

    Hi,

    I'm building a site that can possibly have millions of users (yes ambitious!).  Each user can upload an image or two for his/her profile.  How would you architect the directories to support this type of thing?  I was thinking of having a users subfolder off the root dir where each user will have their own sub-dir that corresponds to their userId created at registration time.  I could then upload their profile pics to their corresponding sub-directory under the users dir.  Seems straightforward but am I missing anything?  Can I have a million sub-dirs under the user dir?  NTFS supports it so my guess is YES.  Please advise.

    TIA,

    Viz

    Saturday, February 6, 2010 11:06 PM

Answers

  • User-389939489 posted

    NTFS supports it but, when you get past the thousand items in a folder, things start slowing down dramatically: this is because the item lookup is a linear search across the items list.

    So, in order to keep those images on the file system, you'd need a less flat hierarchy. In your case, that might look like:

    -- root

    -- -- group_1 (ids from 1 to 1000)

    -- -- -- user_1

    -- -- -- user_2

    -- -- -- ...

    -- -- -- user_1000

    -- -- group_2 (ids from 1001 to 2000)

    etc.

    That said, and from what I can understand of your requirements: IMO yours is the perfect case for storing those images into a database table instead. It's technically trivial, simpler than storing on the file system; OTOH, from a conceptual standpoint, there seems to be no point in seeing those images out of the context of a user profile.

    HTH,

    -LV

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 7, 2010 10:06 AM

All replies

  • User-389939489 posted

    NTFS supports it but, when you get past the thousand items in a folder, things start slowing down dramatically: this is because the item lookup is a linear search across the items list.

    So, in order to keep those images on the file system, you'd need a less flat hierarchy. In your case, that might look like:

    -- root

    -- -- group_1 (ids from 1 to 1000)

    -- -- -- user_1

    -- -- -- user_2

    -- -- -- ...

    -- -- -- user_1000

    -- -- group_2 (ids from 1001 to 2000)

    etc.

    That said, and from what I can understand of your requirements: IMO yours is the perfect case for storing those images into a database table instead. It's technically trivial, simpler than storing on the file system; OTOH, from a conceptual standpoint, there seems to be no point in seeing those images out of the context of a user profile.

    HTH,

    -LV

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 7, 2010 10:06 AM
  • User-345079421 posted

    The best practice here to build one folder lets say (Gallery), the build a table that will contain (GalleryID, UserID, imagedesc).

    then save the uploaded image with GalleryID. so u can link the image with its info in the DB.


    Regards,

    Moayad Faris

    Sunday, February 7, 2010 7:19 PM