I have a WCF service deployed on IIS and using SQL Server 2008 as backend.

My question is: How can I make cluster(load-balance/fail-over) on IIS and on SQL Server and what sort of thing do I need to keep in mind before doing this? (e.g. do I have to move sessions from in memory to SQL server etc.)

Also, how can I make sure that both SQL servers have the mirror data all time and does both SQL servers shares locks (row, page, table) information in real time?

This is my first time on this. Is this called web farming?

  • If this is important (ie, it's for a business, there is money involved, and you need to do it right the first time), then you need to get a consultant to help you do this. It's not terribly difficult, but there might not be much of a margin for error, and it sounds like you don't know anything about the subject. That's helpful criticism, not an insult. Until anyone learns, they are ignorant, and you're seeking to learn. If this is for a hobby project, or you have time to do this in a test environment first, then the answers below will help you do this yourself.
    – mfinni
    Feb 3, 2010 at 16:25
  • Thanks for suggestion but I am not a businessman I am just trying to learn what are the steps or key points to remember while software development process and also i personally don't feel its rocket science and one can learn how to swim if he dares to jump in a deep pool. :)
    – Mubashar
    Feb 4, 2010 at 7:48

3 Answers 3


I guess IIS and SQL are on separate servers:

IIS: You can use Microsoft NLB feature to spread the load between 2 or more servers. They can be Web editions of Windows. It's included in windows. You will have a virtual IP that client will connect to. Servers will "share" this ip and spread client to different server. The multicast/unicast depend on the network, number of nic and intra server communication or not. NLB is not application aware, if you shut IIS, users will be lost if you have affinity. NLB just remove a server if it's down from an ip point of view. You will have to change in IIS metabase (loadbalancercapabilities) as explained here: http://technet.microsoft.com/en-us/library/cc757659(WS.10).aspx From a license point of view, it's included in windows, no more cost.

From WCF point of view: Client will connect to one of the X web servers. You can maintain them on the same servers while this one is working (through affinity). Affinity is based on a hash between client IP and Virtual IP. If a server fail, client will be dispatched to others servers. If you use http sessions/authentication, you will have to store session outside of the server, like on the database. Else client session will be lost when a server fail.

SQL: You have differents options: using SQL mechanism to replicate database, or use Microsoft MSCS (cluster). The last one means Windows enterprise version and external shared storage which imply high cost (but still SQL standard version). Going with SQL pure layer, you can mirror your database. Each server got a local storage, and the primary send transaction on the fly to the standby server (synchrone or asynchrone). When your webserver connect, the server tell him that a standby server is available in case of problem, through the SQL native client and or ADO.Net. So your webserver switch to the standby server automatically in case of problem. This all works with standard SQL version. Databases need to be in full recovery mode. It's per database, so if your WCF use multiple database, and only one is broken, you will have issue because one database is now active on the standby server, but all others are still on the primary server.

More info here: http://technet.microsoft.com/en-us/library/cc917680.aspx

  • hmm Thanks for Detailed answer: Can you just let me know with 2 IIS and 2 SQL Server do i need atleast 5 Servers??? or i can manage to host 1 sql server and IIS on the same machine but keeping security in mind too. and Secondly I heard that SQL Server do not support Active/Active Clustering due to the complexity of Transaction/locking. is this true? and What about Windows NBL services and MSCS licensing are they free( or part of windows or SQL Server) or i have to buy separately. Thanks a Lot for Once again.
    – Mubashar
    Feb 4, 2010 at 7:55
  • 1
    You can reduce to 2 servers, each with iis and SQL Server, even if it's not the recommended way. SQL Server can be used as active/active with SQL replication, not cluster technology. Cluster is for high availability, not load balancing/load spread. I would recommend at least 2 servers this way: Each with IIS and SQL Server. set up NLB for http between the 2 servers, with affinity. On the SQL server, set up database mirroring So you have load balancing for http,failover for SQL. All stick with standard version/ no more fee (but 2 SQL server std license to pay).Check your code can use SQL mirror Feb 4, 2010 at 11:29
  • Does SQL Server replication is reliable enough? I mean is it a tested and recommended way to use where the accuracy of data is really important?.
    – Mubashar
    Feb 4, 2010 at 14:20
  • 1
    You can have database mirroring and replication both synchrone and asynchrone. Synchrone means it wait for the remote server to confirms the write before writing the data himself. So you can't loose data. But if the remote server is slow, it will slow down your performance too. Asynchrone may lead to some data loss, but slow remote server does not impact performance. I would use SQL mirroring / mscs cluster for high availability, and database replication to load balance/ scale out Feb 4, 2010 at 15:10

I got 6 server iis and i also got WCF service to.

I use ARR (Application Request Routing), is an IIS module extension, to route the request to my web farm. it's working very fine.

I also use NLB for my WCF service like Mathieu tell.

For my SQL server i use Hyper-V, two VM for my sql server, with a SQL cluster and windows faileover cluster and Live migration.

I will answer in french, so if some body can translate it's will be appreciate.

Ce que vous devez faire, c'est avoir un serveur de cluster. Ce serveur va servir à maintenir le "heart beat" entre vos deux serveur SQL. Les deux serveur SQL doivent être sur des machines distinct, mais doivent partager le même partage réseaux (SAN ou NAS ou autre). Les bases de donnée sont monté sur un seul serveur à la fois. Lorsque le "heart beat" est brisé, l'autre serveur prend la relève, et monte en une fraction de seconde les base de donnée et votre service est revenue, ceci est le "failover cluster". Lorsque le processus de transfert de serveur commence vous pouvez perdre quelques pings. Ce qui va détruire tous vos connection actuelle vers la base de donnée. La seul facons que vous pouvez être "UP" à 99 % c'est d'y ajouter live migration. Vous avez un 2 serveur Hyper-V (host) qui monte vos deux serveur SQL (un sur chaque host), vous activer le live migration entre vos deux machine virtuel, donc si vous avez à redémarer un host (serveur qui héberge SQL), vous faites un live migration de votre machine sql d'un host à l'autre. La mémoire sera transferer d'un coté à l'autre et vous n'aurez aucune perte de connection. Votre failover fonctionne toujours, donc si c'est la machine virtuelle qui détient le service sql qui plante, alors c'est l'autre qui va prendre la relève et vous perdrez alors quelques ping mais votre service sera remonté très rapidement.

J'epère que cela va vous aider, et désoler pour le francais, mais en anglais j'aurais surement été mal compris.

  • THanks Boinvin Can you tell me what are the sql server clustering scheme i mean how both server get synced. (log shipping, etc.)
    – Mubashar
    Feb 4, 2010 at 7:57
  • I got sql 2008 standar, this version allow you to have 2 sql server un failover cluster. The sql server use the same network share for the database (In my case is a SAN), but suppose to work on network share. When i sql server fail, the second answer and the same data are use so you dont lost data. When you create a sql cluster they got the same ip Adress for the both serveur (it's a virtual adress) Feb 8, 2010 at 14:47

Yes, clustered web servers are normally called web farms (note that the term does not have any SQL databases associated with it, only web servers).

One would normally use a load balancer in front of the webservers.

  • Dear oded I need details like what i need to do what are load-balancers are they software or sort of hardware and other details too like what i need to keep in mind.
    – Mubashar Ahmad
    Feb 3, 2010 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .