Monday, March 5, 2007

A Failover Solution in .NET

Recently, I am developing a windows service for monitoring stock position in the company. During the testing phase, my boss asked me to add a failover mechanism to the application. That means I have to change a stand-alone program to a distributed one at the final stage! After reviewing the architecture of the program, I concluded the only area I need to synchronizeamong the services is an Order DataTable, while the rest data can be retrieved from the samedata source and should be synchronized automatically. So I need a way to synchronize the Order DataTableand it is best to be a free .Net solotion.

I have found the following failover solutions/products:
  1. Distributed Hashtable(DHT)
  2. GigaSpaces
  3. Oracle Berkeley DB
  4. P2P architecture (P2P may not be applicable to the program, but i think it looks interesting.)

These solutions either cost money or not a .NET solution. That means either I have to ask for money which is difficult, if not possible, or I have to change many parts of my code to adopt the solutions. Then I came across the article, "Implementing a Publisher/Subscriber model for .NET Remoting". Looks like .NET Remoting is exactly what I need. That is, I will make my windows service publish and subscribe to the same remote object. Whenever one service processes an order, it passes the order to another service to be processed. Then, the state of the two window services remains consistant. Whenever one service is down or generates no response, another service is ready to process orders instantly.