locked
Is AppFabric a good solution for storing cached images? RRS feed

  • Question

  • Hello,

    I have an existing Asp.Net MVC 2.0 application that is responsible for serving up images to the end user. There multiple terabytes of images. The images are stored in TIFF format, and must be kept that way due to project requirements. Right now when an image is requested, the MVC app converts (on the fly) the image to something that can be displayed in a browser (PNG or JPG) and adds some compression (also on the fly) to make the file a bit smaller and speed up transmission times.

    I am looking at creating some sort of service that would run in the background and do the file conversion and compression up front before the image is ever retrieved, with the goal of cutting out the time needed to do those tasks and speed up the application for the end user.

    I am really new to AppFabric. In my scenario, would AppFabric caching be a good fit? Can one application (the conversion service) write to the AppFabric cache and another application (the MVC 2.0 app) read from that same cache?

    Thanks,

    David

    Monday, July 12, 2010 2:33 PM

Answers

  • At this time, there is no automatic way to make AppFabric store items to durable memory (disk/database/etc). A custom provider would not help, because the provider deals with storing the configuration settings for the cluster (which cache hosts are in the cluster, the named caches, etc). The items themseles are designed to be stored in-memory. With that said, your service that converts the images could store them to durable memory after placing them in the cache. Then the next time you have to populate the cache, you could do this from disk rather than having to retriee the TIFF and perform the conversion again. Or the application could look in the cache first and in the durable location second and only then go to the database to do the retrieval manually as a last resort.

    Jason

    • Marked as answer by racingcow Tuesday, July 13, 2010 3:08 PM
    Tuesday, July 13, 2010 2:35 PM

All replies

  • David,

    Hello. You should be able to use AppFabric Caching for this scenario. Any .NET application can use AppFabric caching. The service could store the converted images into serializable .NET objects. It would then store them in the cache by key name using the Add or Put methods. Once in the cache, the ASP.NET application could retrieve them using the same keys using the Get method. For examples and more information see Using Basic Cache Methods.

    Note that the cache cluster is completely in-memory, so you would need one or more machines that had enough combined physical memory to meet the needs of your application. The cache settings can be used to control when objects expire, and then your application/service would be responsible for repopulating those expired items.

    How large are the individual items that you're storing? Does this information help?

    Jason Roth

    Monday, July 12, 2010 4:34 PM
  • Thanks, Jason. That does help. The individual objects that I am storing will vary in size, but generally are between 40kb and 300kb.

    Is there any way to make AppFabric cache them to durable memory (i.e. hard disk) rather than RAM? Would we need to write our own custom caching provider?

    Tuesday, July 13, 2010 1:33 PM
  • At this time, there is no automatic way to make AppFabric store items to durable memory (disk/database/etc). A custom provider would not help, because the provider deals with storing the configuration settings for the cluster (which cache hosts are in the cluster, the named caches, etc). The items themseles are designed to be stored in-memory. With that said, your service that converts the images could store them to durable memory after placing them in the cache. Then the next time you have to populate the cache, you could do this from disk rather than having to retriee the TIFF and perform the conversion again. Or the application could look in the cache first and in the durable location second and only then go to the database to do the retrieval manually as a last resort.

    Jason

    • Marked as answer by racingcow Tuesday, July 13, 2010 3:08 PM
    Tuesday, July 13, 2010 2:35 PM
  • Thanks, Jason. I think that gives me what I need to know.
    Tuesday, July 13, 2010 3:08 PM
  • how to convert the images serializable .NET objects? can a zip file (with images) be converted to a serializable .NET objects?
    Tuesday, July 20, 2010 10:55 PM