External Blob Storage in Sitecore

Amazon S3By default, Sitecore stores media files as blobs in the database. This is usually good, but if you have a large volume of files, this can become too heavy to handle. So I wrote a Sitecore plugin where you can seamlessly store all the binaries in the cloud.

The advantage of moving this to a cloud storage are

  • Bottomless storage. No need to resize database volumes
  • Reduced stress on SQL Server
  • No need to publish the binaries themselves results in faster publish
  • Faster and simpler database backups
  • Easier to migrate databases between environment
  • Less need for large disk space on dev/test/stage machines
  • Shorter response times (in some scenarios)

The way I implemented this was by overriding the SqlServerDataProvider in Sitecore, so it would store binaries using a separate blob storage provider, instead of directly in the database. I made such provider for Amazon S3, but you could use Azure or any cloud storage provider you like.

The way it works is that when attaching a binary to a blob field, it’ll upload it to the cloud storage and keep blob reference in the Sitecore database as-is, with just a null value, and keep a cached version on local disk to reduce response times. This could potentially make response times even faster than loading the binaries from the database.

The good thing with this is that the cloud binaries doesn’t have to be published, because they’ll always get a new unique id if a binary is changed. Secondly, the binary isn’t accessible unless the binary reference row is published to the web database, so this won’t be a security issue either.

The implementation also includes migration of binaries from and to the cloud, so you can easily migrate existing data to the cloud, or move it back into the Sitecore database. The implementation also works in a mixed scenario, were only some blobs are in the cloud.

Feel free to grab the code from Github:
https://github.com/mikaelnet/sitecore-blob-storage

Leave a Reply