Hi, I was looking for a built-in way to let 2 instances of the same ServiceStack application to talk to each other.

What I'm trying to achieve is:- My application is load balanced, so I have 2 servicestack-based web app that runs on 2 different servers- Both of them have a Memory Cache Client, that I use to cache some custom entities.- When one of those entities change, I want to trigger something on the other application to let it know that the entity changed.

Do you have any idea on how to do that?

Thanks

mythz
—
2018-12-19T13:27:18Z —
#2

If the purposes are to maintain caches in-sync then the easiest solution is to use a distributed cache, i.e. every cache provider except for In Memory Cache.

Generally for communicating between load-balanced servers I'd prefer to use a loosely-coupled pub/sub solution like Redis Pub/Sub or Redis Server Events which utilizes Redis Pub/Sub behind-the-scenes, although since all App Servers would need access to Redis you may as well consider using a Redis Distributed Cache in that case.

Otherwise for point-to-point communications, communicating between server-to-server is no different than client-to-server where you'd just use a Service Client to send Service requests to the other server.

sviluppo1
—
2018-12-19T14:07:15Z —
#3

I'm currently using a Redis Distributed Cache and it works well, but I wanted to improve the performance of the cache by eliminating the round-trip to Redis. Keeping the cache in-memory would be beneficial for performance in heavy cached operations, but it has the syncronization problem.

So you would suggest to have a channel dedicated to the servers, to use as a "cache sync", that each web app subscribe at launch, right? We already have Redis Server Events working, so it would be trivial to implement.

mythz
—
2018-12-19T14:16:04Z —
#4

ok so if you're already using Redis Server Events than you can just send a message to a custom "appserver" channel (which each AppServer subscribes to) with a custom "delete cache" notification which includes a list of keys which you can then forward to your local instances Cache.RemoveAll(keys).

sviluppo1
—
2018-12-19T14:17:38Z —
#5

Ok thanks, good idea. In my case it would be even easier, because the message would be something like "Delete cache for entity type {type}"