how does social networking web site store images?  | Familiar Sight | | Join Date: Jun 2008 Location: Europe
Posts: 128
| | |
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!
|  | Moderator | | Join Date: Nov 2006 Location: Iceland
Posts: 3,740
| | | re: how does social networking web site store images?
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.
|  | Familiar Sight | | Join Date: Jun 2008 Location: Europe
Posts: 128
| | | re: how does social networking web site store images?
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
|  | Moderator | | Join Date: Nov 2006 Location: Iceland
Posts: 3,740
| | | re: how does social networking web site store images?
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.
|  | Familiar Sight | | Join Date: Jun 2008 Location: Europe
Posts: 128
| | | re: how does social networking web site store images?
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: http://www.extremeexperts.com/sql/FAQ/StoreImages.aspx
and this: http://www.oracle.com/technology/pro..._database.html
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
|  | Moderator | | Join Date: Dec 2006 Location: Bangalore ,India
Posts: 7,500
| | | re: how does social networking web site store images?
You can store images in database ,but definately there will be performance issue as the number and size of files grows.
|  | Moderator | | Join Date: Nov 2006 Location: Iceland
Posts: 3,740
| | | re: how does social networking web site store images?
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.
| | Needs Regular Fix | | Join Date: Mar 2008
Posts: 311
| | | re: how does social networking web site store images?
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 :):):)
|  | Moderator | | Join Date: Jul 2006 Location: Pakistan
Posts: 718
| | | re: how does social networking web site store images? Quote:
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. Quote:
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.
|  | Familiar Sight | | Join Date: Jun 2008 Location: Europe
Posts: 128
| | | re: how does social networking web site store images?
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
|  | Similar MySQL Database bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,272 network members.
|