By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,018 Members | 1,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,018 IT Pros & Developers. It's quick & easy.

how does social networking web site store images?

P: 128

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

Nov 18 '08 #1
Share this Question
Share on Google+
9 Replies

Expert 5K+
P: 5,058
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.
Nov 18 '08 #2

P: 128
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?

Nov 18 '08 #3

Expert 5K+
P: 5,058
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.
Nov 18 '08 #4

P: 128
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

Nov 21 '08 #5

Expert 5K+
P: 8,127
You can store images in database ,but definately there will be performance issue as the number and size of files grows.
Nov 21 '08 #6

Expert 5K+
P: 5,058
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.
Nov 21 '08 #7

P: 310
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 :):):)
Nov 25 '08 #8

Expert 100+
P: 801
This is a good approach and practical in your case.
It is more efficient than storing the images in database.
Nov 27 '08 #9

P: 128
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

Nov 27 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.