Serving Lazy Image Thumbnails from Azure Blob Storage - What is Exists Overhead?

I have a site where users upload images. These images are shown in different areas of the site with different thumbnail sizes. Since the site is still undergoing rapid development, I don't want to fix a certain number of large sizes just yet. Thus, I believe I should be generating thumbnails on a lazy basis.

Of the two options that are most effective for this:

  • When I go to serve as a thumbnail, convert the dimensions to the canonical filename (eg "bighouse-thumb-160x120"). Check if the file exists in the blob store with client.GetContainerReference (containerName) .GetBlockBlobReference (key) .Exists (); If it doesn't exist, generate it and save it.

  • When I go to the thumbnail, query my SQL database to see if the thumbnail exists. If it exists, get the blob URI from the DB and emit it as HTML. If it doesn't exist, generate it and update the SQL database.

I've used # 2 in the past, but by design it duplicates the state, which is bad. If the azure request for blobs to exist is scalable, I would prefer to do so. I don't really understand the threading model in Asp.Net. If I have 200 users requesting thumbs up, will my azure Exists name everything going on in parallel? Even if they do, two round trips seem like a very big overhead. My guess is that database postbacks are faster and more amenable to generic caching solutions.

What's the correct answer?


source to share

1 answer

Regardless of the overhead, I pre-generated thumbnails when loading / saving the image. Thus, you shift the burden of generating thumbnails from something that is done many times (image capture) to something much less frequently performed (image saving).

Consider the following scenario where you are lazily generating thumbnails in the first view:

  • Check the existing sketch (yes false

    , remember the first view;))
  • Create a thumbnail
  • Save sketch
  • Send thumbnail to client

With pre-generated sketches, the process is much shorter:

  • Send thumbnail to client


" " - ( !), , , . , , , -.

, , , /. , , , . , .


All Articles