PubSub in Service Fabric with Redis

I’ve been working on a project that uses Fabric and I’m hosting Redis inside the cluster as a simple cache system.

One of things that isn’t baked into Fabric is a pub/sub model for communicating between services  about events that are occuring.

As I’ve got the Redis instance up and running in the cluster I decided to take a look at using the Pub/Sub capabilities in Redis to make this happen. N.B Redis isn’t a guarenteed delivery so use where appropriate, there are lots of discussions around it’s pub/sub model and when/where to use etc.

Turns out it’s nice and easy to get working, I’m a big fan of using RX to make nice reactive programs operating on streams of events and there is already a nice sample combineing Redis and RX in C# here.

In not too long I had just what I wanted and through it might be useful to others so I’ve put together a sample. My sample is here with one “EventPublisher” service pushing out events and an “EventSubscriber” listening to events.

Both services write out what they’re up to as ETW messages so you can view in the diagnostic window.



Lawrence Gripper


Tagged ,

Running Redis in a Service Fabric cluster

I’m working on a project where we’re in need of a cache inside Service Fabric. Now the cache doesn’t need to be durable just nice, quick and easy to use.

So I came up with the idea of running a Redis cache inside the cluster as a stateless service fabric service. The problem with this is that when the cluster re-balances the services between nodes I will lose the inmemory data in Redis (all of it). What I can do is set the movement cost set to ‘high’, to discourage the cluster from reallocating the service between nodes regularly and causing unnecessary loss of the cache. Great read on how and why the Resource Manager allocations services between nodes here, if you’d like to know more.

It’s worth noting that, if I wanted a durable cache, I could look at using Redis Clustering/Redis as a Service in Azure to prevent this occurring but for what we need it’s overkill.

Either way, I got this up and running and have shared the code here with a ReadMe going into more detail for others that are interested in having a play. Hope it’s useful!

Lawrence Gripper


How to make a CI Build for a custom DSC Resource with Appveyor & PowerShell Gallery

A while back I created a custom DSC resource which enabled you to manage packages installed with Chocolatey (awesome package manager for Windows, like apt-get).

You can do some cool stuff with it, like build out a dev box in azure with one script, use for deployment or just to setup your machine after a rebuild.

So it turns out people have been doing just that, it’s had over 1,200 downloads from the PowerShell Gallery!


Not only that but it’s been improved by the community with pull requests adding functionality and improving the resource.


I wasn’t really expecting this to happen so didn’t have a clear idea of how to test, merge and publish these contributions. In the past, on other projects like powergist, I’ve used Appveyor to handle the CI as it’s free for OSS projects and it’s great to use. I thought I’d give it a spin here and see if I could get it to play ball with the PowerShell Resouce.

Continue reading


Get every new post delivered to your Inbox.

Join 357 other followers