Wilgert
Wilgert

Reputation: 706

Can we use Azure Blob Storage for the ImageCache of ImageResizer

We basically use the recommended cloud architecture where the source images are stored in Azure Blob Storage, the imageresizer runs on an Azure App Service and Azure CDN is the CDN layer.

Nevertheless we are running into an issue with ImageResizer v3, Azure App Service deployment slots and DiskCache.

We use a staging slot on our Azure App Service to prevent interruptions. We also use the DiskCache plugin. Without any configuration the imagecache is written to D:\home\site\wwwroot\imagecache\ which is slot specific.

This generates two issues:

  1. When we swap the slots the imagecache that is used is stale and a lot of images will be missing.
  2. We always have a stale imagecache taking up diskspace on our App Service Plan, our advisor at Microsoft has recommended to use Blob Storage instead of the virtual local file system for DiskCache.

I noticed that there is no BlobCachePlugin or S3CachePlugin and I was wondering if there is a good reason for that.

My questions are:

  1. Is there a reason not to store the imagecache in Azure Blob Storage using a custom BlobStorageCachePlugin that implements the ICache interface?
  2. If there is a good reason, what alternative architecture do you advise to avoid the issues with deployment slots?

Upvotes: 2

Views: 838

Answers (2)

ADMX
ADMX

Reputation: 1

If you have a CDN sitting in front of your Web App, then do you need the DiskCache plugin at all (or the requested Blob Storage caching)?

Once the image has been processed by the Web App it is then cached by one of the CDN edge servers, so what purpose would caching it in the Web App/Blob storage serve?

Upvotes: 0

Lilith River
Lilith River

Reputation: 16468

Caches need to be low latency. Putting the cache on Blob Storage would make even cache hits perform terribly, likely adding 800-1800ms per request. If a Redis server were available, there are ways to make this work better, but it will still not perform as well as using low-latency storage.

Solutions to the cold cache problem:

  1. Warm up the staging slot by duplicating real-world requests to it (the ideal situation, since it also warms up non-IR caches).
  2. If that's not possible, then you might consider some kind of scheduled copy between the imagecache folders on each server that 'only adds' files. Don't try to modify or delete files or directories that are actively served.
  3. Use a low-latency distributed filesystem or low-latency shared network drive. Measure the latency, though, because it's going to be a problem unless you have a very good network connection between the servers. There are blob stores that can be fast enough to use for caching, but typically only when you manage them yourself to assure low latency.

This does mean you won't be able to enable autoClean to automatically purge cache entries; set up monitoring for disk usage.

Upvotes: 1

Related Questions