Skip to main content

What cache mechanism to use from Windows Azure

Yesterday, I had a talk with one college about cache mechanism. The true is that Microsoft has a lot of cache mechanism and when we talk about Windows Azure we have so different mechanism that there are times when we don’t know what the best cache mechanism for us is.
We will talk about 3 times of cache mechanism that are supported by Windows Azure:
  • Windows Azure Appfabric Cache (specials service defined by Windows Azure)
  • Co-located Role Caching (in-memory cache – resources are shared between cache and hosted applications)
  • Cache Worker role (dedicate role used only for cache)
From my perspective we have a lot of options. What we should know from the begging about Windows Azure Appfabric Cache is that be used in combination with Windows Azure of course, but from what I saw until now we cannot have a combination between co-located role caching and Windows Appfabric Azure Cache or Cache Worker role and Windows AzureAppfabric Cache.
Why we cannot combine them? Because the last two cache mechanism offed by Windows Azure can be accessed only from the deployments roles (NOTE: A deployment can have 1...n number of applications and roles). Because of this we cannot make this type of combination.
Windows Azure Appfabric Cache is a good solution when we need a cache mechanism that needs to be shared between different servers. It is not mandatory all servers to be hosted by Windows Azure. Using this cache mechanism we will be able to use our cache from any machine in the world that has internet connection. Don’t forget about an important think about this cache mechanism. Any machine that has the credentials of our cache can access it.
The other to cache mechanisms is very powerful mechanism that can be used by our application. When we need a cache mechanism for our application to be used only by our application I think that this caches are the best. What do decide to use? Co-location caching or cache worker role. The decision is not very simple. The good part is that the switching between them is very simple. Using the configuration file of our application we can very easy change the cache mechanism. Only when we make a switch between this and Windows AzureAppfabric Cache, in some case we will need to add some assemblies, but the API are very similar.
If we have a simple application, that doesn’t consume many resources; we can start with Co-located role caching. If the size of cache increase or/and resources that are used by our application increase also we could switch to Cache worker role. When we use the Cache worker role, we will have a dedicated role used only for cache. For a medium or big application this could be a better solution. Our resources of the roles will not be shared with the cache and also we will know that we will have a dedicated role only for cache.
But if we will have only a Cache worker role what will happen if the role crash. We will lose all data from cache. An option is to activate the automatic backup that will be made on our storage account. In this way the cache will be back-up automatically and restore when is needed. But until the role is restored we will have a period of time when the cache will be down. Also the cache data that is restored could not be with the last cache data (not all data from cache is backup in real time).
From what we saw, if we begin to use Cache worker role, a good decisions it would be to use two instances of Cache worker role if we want to be sure that we have a good uptime. But from my experiences, it is not very often that a role crash because of Microsoft. I n the case we have applications that dependents of crash and need to be up 100% of time use two instances of Cache worker roles of co-located cache.
If you have some data that need to be used only by one role from the application (for example some client information) than Co-located role cache could be a better solution. The time necessary to access this cache is the lowest one because the data are in the memory of the role (in general). Because you can define more caches (by name) in the same Co-located role you can group the data from that need to be stored in the cache.
It is not very simple to decide what cache mechanism to use from Windows Azure. If we need a cache mechanism that is used by different application, Windows Azure Cache can be a good decision, but is hard to decide to decide what to use between Co-located role cache and Cache worker role. For medium to big application I recommend Cache worker role. At start is okay to use Co-located role but after make a switch to Cache worker role. If you have application that doesn’t use all the resources of your role that Co-located role could help you to save some money. Don’t forget that the switch between these cache mechanisms is very easy. Almost all can be done from the configuration file.

Comments

Post a Comment

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(...

How to audit an Azure Cosmos DB

In this post, we will talk about how we can audit an Azure Cosmos DB database. Before jumping into the problem let us define the business requirement: As an Administrator I want to be able to audit all changes that were done to specific collection inside my Azure Cosmos DB. The requirement is simple, but can be a little tricky to implement fully. First of all when you are using Azure Cosmos DB or any other storage solution there are 99% odds that you’ll have more than one system that writes data to it. This means that you have or not have control on the systems that are doing any create/update/delete operations. Solution 1: Diagnostic Logs Cosmos DB allows us activate diagnostics logs and stream the output a storage account for achieving to other systems like Event Hub or Log Analytics. This would allow us to have information related to who, when, what, response code and how the access operation to our Cosmos DB was done. Beside this there is a field that specifies what was th...

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills)

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills) The idea that moving to the cloud reduces the costs is a common misconception. The cloud infrastructure provides flexibility, scalability, and better CAPEX, but it does not guarantee lower costs without proper optimisation and management of the cloud services and infrastructure. Idle and unused resources, overprovisioning, oversize databases, and unnecessary data transfer can increase running costs. The regional pricing mode, multi-cloud complexity, and cost variety add extra complexity to the cost function. Cloud adoption without a cost governance strategy can result in unexpected expenses. Improper usage, combined with a pay-as-you-go model, can result in a nightmare for business stakeholders who cannot track and manage the monthly costs. Cloud-native services such as AI services, managed databases, and analytics platforms are powerful, provide out-of-the-shelve capabilities, and increase business agility and innovation. H...