Clustering IIS and SQL Server

clusterweb-farm

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?

Best Answer

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

Related Topic