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