not sure if this would be the right forum, but what is the best way to store images for profiles of a social networking type site? image server? folder for each user? i'm looking for speed. thanks.
Image server would increase speed. * Rename uploaded file to a random # * Insert that random name into the database & associate it with the user. Peace,
It really depends. For very small images (thumbnails, smileys, etc.) a database is usually more convenient because all your datas are stored together in one place, and backups are easy. Databases however usually don't like storing large binary datas, so for big pictures you might want to store them on a server and keep track of them in the database (if you have a table dedicated to pictures, you can use the primary key to name each file for example)
The best system I think is putting them into directory called say images. Then from there just giving them the name of the primary key + random #. So maybe you do 292-3939393 with the longer number being the date. Of course for keeping things sane you may want to do a structure like say: images/userid/key-date.jpg
mmm, BLOB's baby! Gotta love having everything contained in a database. For speed, this isn't the prime solution but their are many advantages to using db-contianed blob data. Like: - Ability to protect your binary files (not accessible anywhere). - Ability to backup, modify, create new data and not worry about file/folder permissions - many more....
Do not store your images in database it will dramatically decrease your server speed. More over there is no point in keeping binary data in database, what will you do with it besides taking huge amounts of data from your database just to display an image. Keep them in folders, how to organize them? It is up to you, you can create folder for every user, keep all images in one folder named like userId-img543.jpg etc.
That's an issue easely fixed: use a script and/or mod_rewrite to cache the image on the Web server so that it is only retrieved from the database once in a while.
hum, I vote to this solution: - ease of portability and backup - speedup but there's a drawback, storing images in blobs fields will enlarge your databases backups and restores.... maybe using a different DB for images? the solution for this kind of problem is like the chicken or the egg problem!
Well but it doesn't change a fact that image is already in your database so whenever you want take something out of this database, images you are storing in DB are "slowing down" your database. This is a partial fix then.
That really depends. Take for example MySQL with the default MyISAM tables: each table has its own file. So stuffing lots of pictures in one table has no impact on the other tables, and as such no impact on their speed.