java – Spring boot – best way to store images (SQL backend)

java – Spring boot – best way to store images (SQL backend)

I think its a really bad idea to store images in DB. you need to store only image links in DB (table with columns: user_id, profile_image_url), and image files should be stores in any distributed file system (like amazon S3)

SQL Server support blob storage inside the database, and also can integrate with Windows to store blobs in the file system (providing access both through TSQL and Windows APIs).

The features are called Filestream and FileTables

The intent of these features is to provide the best-of-both-worlds for storing blob data. SQL Server manages the consistency, availability and recoverability of all your application data, but large files are stored outside the database.

But the real point here is that since SQL Server supports storing blob data either inside the database files, or in the filesystem, Microsoft did a bunch of testing to help customers decide which was the better choice.

The testing resulted in a rule of thumb that under about 1MB in-database storage performs better than the file system, and above that the file system is better. Basically external blobs have lower per GB cost and better streaming performance, but have higher per-file-access cost for opening, creating, deleting, etc. And the breakeven point is around 1MB.

See eg this whitepaper on Filestream Storage

java – Spring boot – best way to store images (SQL backend)

Leave a Reply

Your email address will not be published. Required fields are marked *