Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scaling out WCF, how to deal with callbacks?

Tags:

c#

.net

wcf

Suppose, I want to scale out (add more boxes) some WCF service. This looks pretty easy, set up load balancer that calls WCF services on multiple boxes using for example round robin algorithm.

However how to deal with situation when a WCF service have callback contract. When a client connects to some particular box, it receives events only raised by this computer WCF service instance. And I want client to receive events that were raised by any WCF service instance in group (cluster).

What is the best way to make WCF service know about events raised by other WCF service instances?

Some ideas: Multicast, broadcast, WCF NetPeerTcpBinding, Single server that subscribes to all WCF services in cluster (acting as event aggregate).

UPDATE: I have managed to create test system, using NetPeerTCPBinding as a mechanism to share events across servers. I haven't made a benchmark yet, but I feel that WCF P2P is to heavy for this tusk, I'm gonna implement UDP broadcast based event sharing system.

like image 317
Alex Burtsev Avatar asked Jan 27 '12 12:01

Alex Burtsev


1 Answers

I would implement this by setting up a MSMQ queue that each server can subscribe to, and when an event occurs that the other servers need to know about, the service can publish it.

I use a library called NServiceBus to make this entire process simple. NServiceBus is a full-featured library that uses MSMQ (among other transports) to create pub/sub messaging buses, which would exactly solve your problem. It is easy to use and has a fluent interface for configuration, subscription, and publishing.

I will come back and edit this post later with an example, but the NServiceBus website has plenty of documentation to get you started until then.

like image 82
Steve Czetty Avatar answered Oct 03 '22 21:10

Steve Czetty