Orleans vs a Distributed Cache

I’m often asked what the difference is between Orleans and a distributed cache. It’s a good observation because on the face of it they have similar aims, to hold objects in memory for the right period of time to provide a performance benefit.

However, there are a number of differences.

  1. The grains in Orleans are programmable, whereas caches normally just store data.
  2. With a distributed cache you keep objects in memory, but there’s a good chance that the data doesn’t reside on the same machine that’s serving the request. This means that machine processing the request has to retrieve the data from another node. Orleans will send the request to the machine which holds the data, which in theory should be more efficient.
  3. Orleans queues message to each grain and processes them one by one with a single threaded programming model. This stops concurrency problems and race conditions. With caches you have to build a locking system yourself, as described here for memcached.
  4. A grain can register a timer so it can call itself without requiring an external request. Caches generally just respond to external requests.

People are certainly using Orleans as a cache, but I think it’s capable of much more.