Trying Redis Caching as a Service on Windows Azure
First, if you have already have an MSDN subscription (through your work, whatever) make sure to link your MSDN account and an Azure Account, otherwise you're throwing money away. MSDN subscribers get between US$50 and US$150 a month in free Azure time, plus a 33% discount on VMs and 25% off Reserved Websites.
Next, log into the Azure Preview Portal at https://portal.azure.com. Then, go New | Redis Cache to make a new instance. The Redis Cache is in preview today and pricing details are here. both 250 meg and 1 GB caches are free until July 1, 2014 so you've got a week to party hard for free.
Of course, if you're a Redis expert, you can (and always could) run your own VM with Redis on it. There's two "Security Hardened" Ubuntu VMs with Redis at the MS Open Tech VMDepot that you could start with.
I put one Redis Cache in Northwest US where my podcast's website is. The new Azure Portal knows that these two resources are associated with each other because I put them in the same resource group.
There's Basic and Standard. Similar to Website's "basic vs standard" it comes down to Standard you can count on, it has an SLA and replication setup. Basic doesn't. Both have SSL, are dedicated, and include auth. I'd think of Standard as being "I'm serious about my cache" and Basic is "I'm messing around."
There are multiple caching services (or Cache as a Service) on Azure.
- Redis Cache: Built on the open source Redis cache. This is a dedicated service, currently in Preview.
- Managed Cache Service: Built on AppFabric Cache. This is a dedicated service, currently in General Availability.
- In-Role Cache: Built on App Fabric Cache. This is a self-hosted cache, available via the Azure SDK.
Having Redis available on Azure is nice since my startup MyEcho uses SignalR and SignalR can use Redis as the backplane for scaleout.
Marc Gravell (with a "C") over at StackExchange/StackOverflow has done us all a service with the StackExchange.Redis client for .NET on NuGet. Getting stuff in and out of Redis using .NET is very familiar to anyone who has used a distributed Key Value store before.
- BONUS: There's also ServiceStack.Redis from https://servicestack.net that includes both the native-feeling IRedisNativeClient and the more .NET-like IRedisClient. Service Stack also supports Redis 2.8's new SCAN operations for cursoring around large data sets.
ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("contoso5.redis.cache.windows.net,ssl=true,password=...");
IDatabase cache = connection.GetDatabase();
// Perform cache operations using the cache object...
// Simple put of integral data types into the cache
cache.StringSet("key1", "value");
cache.StringSet("key2", 25);
// Simple get of data types from the cache
string key1 = cache.StringGet("key1");
int key2 = (int)cache.StringGet("key2");
In fact, the ASP.NET team announced just last month the ASP.NET Session State Provider for Redis Preview Release that you may have missed. Also on NuGet (as a -preview) this lets you point the Session State of your existing (perhaps legacy) ASP.NET apps to Redis.
After pushing and pulling data out of Redis for a while, you'll notice how nice the new dashboard is. It gives you a great visual sense of what's going on with your cache. You see CPU and Memory Usage, but more importantly Cache Hits and Misses, Gets and Sets, as well as any extraordinary events you need to know about. As a managed service, though, there's no need to sweat the VM (or whatever) that your cache is running on. It's handled.
From the Azure Redis site:
- Redis is an advanced key-value store, where keys can contain data structures such as strings, hashes,lists, sets and sorted sets. Redis supports a set of atomic operations on these data types.
- Redis also supports trivial-to-setup master-slave replication, with very fast non-blocking first synchronization, auto-reconnection on net split and so forth.
- Other features include Transactions, Pub/Sub, Lua scripting, Keys with a limited time-to-live, and configuration settings to make Redis behave like a cache.
- You can use Redis from most programming languages used today.
- Azure Redis Cache leverages Redis authentication and also supports SSL connections to Redis.
Perhaps you're interested in Redis but you don't want to run it on Azure, or perhaps even on Linux. You can run Redis via MSOpenTech's Redis on Windows fork. You can install it from NuGet, Chocolatey or download it directly from the project github repository. If you do get Redis for Windows (super easy with Chocolatey), you can use the redis-cli.exe at the command line to talk to the Azure Redis Cache as well (of course!).
It's easy to run a local Redis server with redis-server.exe, test it out in develoment, then change your app's Redis connection string when you deploy to Azure.
Sponsor: Many thanks to our friends at Octopus Deploy for sponsoring the feed this week. Did you know that NuGet.org deploys with Octopus? Using NuGet and powerful conventions, Octopus Deploy makes it easy to automate releases of ASP.NET applications and Windows Services. Say goodbye to remote desktop and start automating today!
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
Service Stack also supports Redis 2.8's new SCAN operations for cursoring around large data sets.
Just to clarify - that is also available in SE.Redis
The only disconcerting thing is that this is the 4th go Azure have had at caching, hopefully they are settled now! The Managed Cache Service seemed to be out of favor (removed from the portal) the day it was released.
The redis is persistent (database key-value)? and the Managed Cache Service is completely in memory?
We recommend using Azure Redis Cache for new Developments - http://msdn.microsoft.com/en-us/library/dn766201.aspx
Both Azure Managed Cache and Azure Redis Cache work great as a traditional caches i.e. as performant key value stores.
However unlike traditional caches which deal only with key-value pairs, Redis is popular for its highly performant data types. Redis supports running atomic operations on these types, like appending to a string; incrementing the value in a hash; pushing to a list; computing set intersection, union and difference; or getting the member with highest ranking in a sorted set.
Other features include support for transactions, pub/sub, Lua scripting, keys with a limited time-to-live, and configuration settings to make Redis behave more like a traditional cache.
You can read more about Redis at redis.io
We do feel very confident recommending Redis cache as long term bet to customers for it is a proven Cache engine, with a a vibrant open source community around it.
-But that can be Your personal fun stuff. MSDN Subscriptions are personal even if they are purchased by your employer.
http://blogs.msdn.com/b/kenkilty/archive/2014/07/03/asp-net-session-state-using-sql-sever-in-memory.aspx
We have having problems with performance and reliability on azure's managed cache for session state and we are looking for an alternative.
Is there is any performance data on managed cache vs redis cache for session state?
Thanks!
Comments are closed.