Jump to content

Best Practice to Storing and Displaying a Lot of Images


Recommended Posts

Hi all,

 

In one website, I read the following note:

 

"You should also think about storing files locations on disk. Using MySQL for storing images is thought to be Bad Idea™. Handling SQL table with big data like images can be problematic."

 

  1. Do you agree? If not, why?
  2. What is the best practice in storing and displaying on a website a big number of images?
Link to post
Share on other sites

That's correct. Only data that needs to be searchable should go in the database. Files should go in the filesystem.

 

Best practice, create a directory structure to organize your images and store their names and path information in the database.

Link to post
Share on other sites

It's pretty easy to figure that out for yourself, also. Create an image gallery page that shows 20 or 30 images. Have one version that loads the binary image data directly from the database, and another version which only stores the filenames and has the binary image files on disk. Load that page and see if it's faster to send the server 30 database lookups or 30 requests for files.

Link to post
Share on other sites

Consider integrating a service like Amazon's Simple Storage Service (S3) into your application if it relies heavily on managing / delivering files. Files would get uploaded to a bucket, and the path stored in the database. Use it with Cloudfront to get CDN capabilities too.

https://aws.amazon.com/s3/

https://aws.amazon.com/cloudfront/

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...