locked
Cache Write Strategy RRS feed

  • Question

  • There are write-through and write-back strategy in CPU caching, however, I didn't find similar materials about windows azure cache. 

    Write-through can be implemented by writing results back to permanent storage like windows azure storage table or blob.

    But how can I implement write-back strategy? Notification?


    Friday, November 30, 2012 8:53 AM

Answers

  • Hi,

    Windows Azure cache does not allow us to control such cach strategy directly. But under the hook, a strategy similar to write-back is used. When you write something to the cache, the in-memory copy is updated immediately, but the remote copy (if the cache server is not the current instance) is updated at a later time. This way, if you update the cache again within the period, the dirty data does not need to be sent to the remote cache server.

    In addition, Windows Azure cache does not store the data in a permanent storage like blob or table. It stores the data in memory, either local memory or remote memory. All servers are located in the same data center with extremely high bandwidth, so write to a remote machine's memory is more efficient than write to local disk.

    Best Regards


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    • Marked as answer by Johnson - MSFT Monday, December 10, 2012 4:56 AM
    Sunday, December 2, 2012 7:05 AM

All replies

  • Hi,

    Thank you for your post.

    This is a quick note to let you know that we are performing research on this issue.

    This may take some time. Thanks for your patience.

    Best Regards


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Saturday, December 1, 2012 8:04 AM
  • Hi,

    Windows Azure cache does not allow us to control such cach strategy directly. But under the hook, a strategy similar to write-back is used. When you write something to the cache, the in-memory copy is updated immediately, but the remote copy (if the cache server is not the current instance) is updated at a later time. This way, if you update the cache again within the period, the dirty data does not need to be sent to the remote cache server.

    In addition, Windows Azure cache does not store the data in a permanent storage like blob or table. It stores the data in memory, either local memory or remote memory. All servers are located in the same data center with extremely high bandwidth, so write to a remote machine's memory is more efficient than write to local disk.

    Best Regards


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    • Marked as answer by Johnson - MSFT Monday, December 10, 2012 4:56 AM
    Sunday, December 2, 2012 7:05 AM
  • Thanks for your reply.

    So does that mean I don't need to write data in cache into some backup storage in case that the data get expired or evicted because Windows Azure Cache will automatically do that thing for me?

    Monday, December 3, 2012 8:05 AM
  • Hi,

    If you want to store persistent data, then please do not write to cache, you can write to a storage service instead (such as blob, table, and SQL). Usually, cache is used to store temporary data. One commonly used approach is to store a cached copy of an item from storage service, so future read only requests will read from either local memory or the cache server, not storage service. But you need to explicitly write back to storage service if you want change of the data to be persistent. Using distributed cache, if your local server crashes, cache data will not lose, so it is not needed to read from storage service again. But if a cached item expires, it is automatically deleted from cache.

    This is similar to CPU cache. If you want the data to persist, write it to the local disk rather than in CPU cache. CPU cache is automatically written to memory but not disk, and will be deleted if PC is turned off. Similarly, Windows Azure cached data will automatically be written to cache server, but not storage server.

    Best Regards


    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 3, 2012 9:46 AM
  • Hi

    Currently there is no mechanism of write through/write behind in Windows Azure Cache. You could try using cache aside pattern for your requirement.

    Tuesday, December 4, 2012 7:32 AM
  • Hi,

        Thanks for replying.

         Here is my thing, I have several worker role instances that will write data into the same cache  location frequently. And web roles will compute a result based on the data in that location as response to client's requests. If client never initiate request within the expiration period, that data will get expired and removed from cache. But since write to that cache location will be frequent, a write through strategy(implement a write-through to blob following right after write to cache) obviously not a good plan,  I am wondering a way of implementing write-back strategy that could notify me of writing cached data into blob when the cached data is about to get expired. 

       If there is no such mechanism, it seems I could only directly write the data into blob.

       Do you have any suggestion about that? 

       Any reply will be welcome. Thanks.

    Wednesday, December 5, 2012 3:32 AM
  • You won't get notified when a cache is about to expire. However, in most cases it makes sense to write all cached items that are older than a specific time (such as one minute) to blob storage. If the web role has processed the item within the time limit, then it can be safely deleted from cache, and does not need to be written to blob.

    Best Regards


    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 6, 2012 9:24 AM