1

I wish to store a considerable amount of images for a web application. The web application will have little writes/uploads but heavy reads.

From reading on the Internet, I have come to believe that:

  • Images must NOT be stored in a database but on the file system of a machine.
  • The database tables must only store the path to the images.

Consider a typical web application's minimal architecture:

minimal architecture

I have several queries as follows:

  1. The web application's code first fetches the image path for an employee from the db and then the actual image from another remote machine. How will the web application access the images stored on a remote machine? Please check this detailed thread discussing reading/writing remote files. As shown in the figure, which approach should I take?

  2. Will document DBs like MongoDB make sense if used for storing images?

  3. It is quite possible that the IP addresses of the machines in consideration will change. Suppose the image server's IP address changes. What's the best way to handle this situation? Something like <IMAGE_IP>/<FIXED_FILESYSTEM_PATH> could be stored in the DB and used by the web application during access, but are there better ways?
  4. The topic of image storage for this setup is not clear to me. What exactly should be stored as the image 'path' in a relational DB's table (e.g: Employee)?

Please correct/suggest better than my assumptions.

Thanks and regards!

Community
  • 1
  • 1
Kaliyug Antagonist
  • 3,512
  • 9
  • 51
  • 103

1 Answers1

0

I recently finished Udacity CS-253 Course. The answer is there in your question.

"images must NOT be stored in a database but on the file system of a machine. The database tables must only store the path to the images "

The DataBase hit is a cost factor. So to zero database reads for use memcash.

Read Lesson six of Udacity CS-253.