Jump to content

Best Practice to Storing and Displaying a Lot of Images


j.silver

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 comment
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 comment
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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...