views:

184

answers:

1

So it's easy to load balance an ASP.NET web application. You set up a load balancer between two servers, and if the web server isn't responding on Port 80, it won't receive requests.

Are there any proven techniques for doing this for a C# console application or Windows service that takes actions of its own volition? Are there any frameworks for knowing if peer processes are alive or dead, doing heartbeats, etc?

I've been experimenting a bit with NServiceBus and it seems like, for certain kinds of applications, it would help to have most of the work done as a response to an event, which makes it more like a web application, actually, and therefore easier to scale and load balance with multiple processes, but I feel like that's a half-baked solution since in most cases there usually needs to be some concept of a "master" process that's responsible for getting work started.

+2  A: 

NServiceBus does indeed handle this for you with its Distributor process (described here: http://www.nservicebus.com/Distributor.aspx). The generic host that comes with NServiceBus allows you to have the exact same code and configuration run both as a console app and as a windows service (described here: http://www.nservicebus.com/GenericHost.aspx).

You can have this for events as well as for regular command messages.

If you want a "master" process to decide what to do when all the load-balanced work completes, that is provided to you in the form of the saga infrastructure (described here: http://www.nservicebus.com/Sagas.aspx and demonstrated in the Manufacturing sample that comes with NServiceBus).

In short, you should pretty much be covered.

Udi Dahan
Udi, thanks for your answer! Do you know of any links for examples of using Sagas to create a master process functionality? Unfortunately, my Manufacturing sample is breaking - when I try to run it Visual Studio asks to find the source to a FacadeToIsolatedServiceController.cs on a D drive that I don't have. When I can't locate it, I get a Failed to complete setup of assembly - Probing terminated in the OrderService. (NServiceBus 2.0.0.1145)
David
I discovered that the problem was that I have a 64-bit OS and had not noticed that System.Data.SQLite.dll had an x64 version. The Manufacturing sample is now running and I will try to learn what I can, but if you know of any links those would definitely still be appreciated.
David