how does social networking web site store images?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bilibytes
    New Member
    • Jun 2008
    • 128

    how does social networking web site store images?

    Hi,

    i am wondering how did a website like facebook, myspace or whatever social networking site store their images?

    do they store them in a DB or roughly like files?

    thankyou in advance and

    cya!
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Without actually knowing anything about it, I would guess they have a central storage system that is probably very much database driven.
    But being huge as they are, they would require an advanced caching system that spans multiple servers around the world. That system would not necessarily have to rely on a database, but rather "mirror" the actual image from the central database as a file served from the file-system.

    But like I say, I don't really know what they actually do. I'm just guessing.

    Comment

    • bilibytes
      New Member
      • Jun 2008
      • 128

      #3
      I want to create a site with just profile pictures, but as i read you, it's quite complicated...
      do you think it would work to have profile pictures saved on a databasw? or it would be too slow to retrieve data, or worse it would crash...?
      i know this is a matter of size, if i have 2 users its ok but if i have lets say:
      ---------------------------
      5,000 users that request their friends profile picture 20 times a day?
      it would make -> 10,000 requests per day with:
      1 picture per friend -> 50 friends per user ->
      500,000 pictures in a day-> concentrating the users visits in 6 hours per day it makes->
      83,000 pictures per hour->
      1,300 pictures per minute->
      23 pictures per second-> with a picture size of 12 KB per picture->
      -----------------------------------
      |....276 KB per second...|
      |______________ ______|

      and that is for an average volume, it would maybe raise to 200 mega per second i dont know...
      will mysql be able to handle this?

      thankyou

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        I try to avoid putting *files* into a database when I can, except when there is a good reason to do so. Like, for example, when you need extra security.
        It is generally considered a bit less efficient to store files inside a database, so unless you have a good reason to, you really shouldn't do it.

        In your case I see no reason or benefit from putting the images inside a database. Having them on the file-system and simply allowing the HTTP server to serve them from there sounds perfectly fine, and it might help a bit with the overhead.

        Comment

        • bilibytes
          New Member
          • Jun 2008
          • 128

          #5
          thankyou very much!

          but the problem is that i could not forbid some users to see some images and allow others.. well, if i can i don't see how!

          if you have any link from where i could read about this, i would be very grateful.

          thank you again

          Edit Post:
          for those who are also interested, i have searched and found this:

          and this:



          it seems to point now that it's better to put images in databases, but these two articles were written by subjective people so i don't know what amount of trustiness give to them.

          so i beg experts you please have a look at it and bring some light into this topic

          thank you very much

          bilibytes

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            You can store images in database ,but definately there will be performance issue as the number and size of files grows.

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              Ahh ok. So you do need to restrict access to some of the images?

              If that is the case, then you may well be best of putting them into a database.
              But that can affect the server performance.

              You could of course also put the images on the file-system, out of reach from the public, and have PHP read them from there into the output. Might help a bit with the performance.

              Comment

              • coolsti
                Contributor
                • Mar 2008
                • 310

                #8
                You can leave the images as files located someplace off the document tree so that they are not directly accessible via a browser. But place them in a directory that is accessible to PHP or whatever scripting you are using for your site.

                You can store the filename or if needed also the directory path information of the user's active profile picture in the database. This would only be saving some text in the database rather than the entire image file. Access would therefore be quick.

                You then need to write your scipts so that they read the filename (and maybe directory location) from the database, and then serve the correct profile image to the page. If the image itself is located off of the document tree, it cannot be accessed with a simple html image tag soyou will need to do some trick here to do this, but it can be done.

                No idea how efficient this would be, nor how the job is really done on other sites.

                By the way, as an aside, does anyone know what the "needs regular fix" under my signature is supposed to mean :):):)

                Comment

                • mwasif
                  Recognized Expert Contributor
                  • Jul 2006
                  • 802

                  #9
                  Originally posted by coolsti
                  You can leave the images as files located someplace off the document tree so that they are not directly accessible via a browser. But place them in a directory that is accessible to PHP or whatever scripting you are using for your site.
                  This is a good approach and practical in your case.
                  Originally posted by coolsti
                  No idea how efficient this would be, nor how the job is really done on other sites.
                  It is more efficient than storing the images in database.

                  Comment

                  • bilibytes
                    New Member
                    • Jun 2008
                    • 128

                    #10
                    Ok thank you for your replies I think storing the url in databse is the best aproach for a small site, then if it grows, i think i should use other triks

                    tkanyou very much

                    bilibytes

                    Comment

                    Working...