简体   繁体   中英

Broadcast messages between nodes in Azure Service Fabric

I have a scenario where I am maintaining a cache in all the nodes of my Service Fabric Cluster. I am looking into a situation where if I get a request from the load-balancer to one of the node regarding updating the cache, can that node (which received the request) broadcast or in any way tell other nodes that the cache needs to be refreshed and they all refresh the cache.

If you are not already using a Reliable dictionary (which is already replicated across the nodes) or Redis cache(as suggested in the comment) and you have a custom solution for caching, you can introduce Azure Event Grid in your architecture and introduce topics and subscriptions. Essentially the nodes would subscribe to the topic for updating the cache and perform the update.

Since every node is at the same time and sender and subscriber, with the cache, changed notification, you can incorporate the token(for example random GUID) that publishing node would send and keep locally, so when event handler for the topic is triggered, you check whether locally stored token matches the token sent by the publisher.

If not - update the cache, if yes - no action needed.

You can use this OSS library to do pub/sub messaging inside SF. You'd publish a refresh message, and all subscribers would update their cache upon receiving the message.

Check the examples to get started.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM