Storing images in NoSQL stores

Whether or not to store images in a DB or the filesystem is sometime one of those “holy war” type of debates; each side feels their way of doing things is the one right way. In general:

To store in the DB:

  • Easier to manage back-up/replicate everything at once in one place.
  • Helps with your data consistency and integrity. You can set the BLOB field to disallow NULLs, but you’re not going to be able to prevent an external file from being deleted. (Though this isn’t applicable to NoSQL since there aren’t the traditional constraints).

To store on the filesystem:

  • A filesystem is designed to serve files. Let it do it’s job.
  • The DB is often your bottleneck in an application. Whatever load you can take off it, the better.
  • Easier to serve on a CDN (which you mentioned isn’t applicable in your situation).

I tend to come down on the side of the filesystem because it scales much better. But depending on the size of your project, either choice will likely work fine. With NoSQL, the differences are even less apparent.

Leave a Comment