ASP.NET MVC Image Storage Location (db vs filesystem)

I am writing a web application using the ASP.NET MVC + NHibernate + Postres stack. I wonder if you should save the downloaded images to the database as binary drops or the file system (and the link only in db). One of the advantages of the db repository that I can think of is the simple backup / restore of all data without resorting to file system copy tools. On the other hand, I suspect that access to the file system may be faster (but is it especially when dealing with many concurrent requests?) What are your suggestions?

+5
source share
3 answers

I would do this: make sure that the images are stored in the database, so that all the data is centralized for easy backup, but also cache the data from the outside, so that repeated requests for large images do not break the database buffer cache. Done correctly, you can add new front-end web servers that will transparently populate your local image cache from the database after startup.

Having a centralized repository for images is also useful to ensure that you send good Last-Modified and ETag HTTP response headers for images on a multi-web server system, as these headers can be made from database content rather than from local objects. cache.

PostgreSQL: " " , , "": PostgreSQL, ( zlib, - ) TOAST, , . . "SET STORAGE" ALTER TABLE, :

ALTER TABLE media.image ALTER COLUMN content SET STORAGE EXTERNAL
+2

, , -.

, , , .

blob , blob " " /. , . , "" , - .

( ), , ( , ).

.

+2

It depends. Do you appreciate the possibility of a direct link to an image or want to always use resources on the server side to call the database, and then write binary data for the image?

+1
source

All Articles