Click here to Skip to main content
11,924,280 members (66,895 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked

Managing server failover in WCF

, 4 Mar 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
In this article I will talk about server failover and how to manage it.

Sample Image


In this article I will talk about server failover and how to manage it.

Solution Summary

Here is the message sequence diagram for a vanilla case.

Sample Image - maximum width is 600 pixels

Here is the problematic scenario that we are going to solve:

  • Concurrency problem. In our case it could happen that some services send messages at the same time. This problem will be solved with the Vector Clock algorithm.
  • Critical section - System activation should be performed in the critical section.

Pseudo code

procedure OnMessageArrived(msg)
    isGreater = msg.VectorClockTimeStamp > currentVectorClockTimeStamp
    isLess = msg.VectorClockTimeStamp < currentVectorClockTimeStamp

    if ( isGreater ) then
        currentClockTimeStamp = msg.VectorClockTimeStamp
    else if ( isLess == false )
         concurrency error 
    end if    
    call appropriate message handler
procedure Activate(msg)
    if ( AcquireLockFromAllServicesApproved() ) then
        isActivated = true
    End if

procedure Deactivate(msg)
    isActivated = false

//message handlers     

procedure HandleHeartBeatFromOther(msg)
    //do something

procedure HandleOtherSystemAcquiredLock(msg)
    if (CurrentSystemInLock)
        return LockNotAprooved;
        return LockAprooved;
    End if
procedure HandleOtherSystemReleasedLock(msg)
    //do something


  • Download demo and runner.bat.
  • Three applications will be created, just press Start.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Dima Zevelev
Software Developer (Senior) Better Place
Israel Israel
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151125.3 | Last Updated 4 Mar 2013
Article Copyright 2013 by Dima Zevelev
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid