In one of our project the site usage of site was very heavy and we need to
migrate it to load balancing server. I have never configured the sites in the
load balancing server but it was quite interspersing experience Here are the
some points which we need to take care while we move asp.net sites into the load
balancing environments. So first we will see what is load balancing.
Following is a load balancing definition from the Google.
In computer networking, load balancing is a technique to distribute workload
evenly across two or more computers, network links, CPUs, hard drives, or other
resources, in order to get optimal resource utilization, maximize throughput,
minimize response time, and avoid overload.
Following are the points which you need to take care when you are deploying your
asp.net sites into load balancing server environments.
Machine Key Should be same for both servers: View state and session both
are depends on the machine key. If you machine key is not same then you will
have problems related to session and view state you may loose your session and
view state in between request during post backs. If machine key will not be same
then its possible that you can get strange result in Ajax requests. There is a
machine key section in web.config where you can specify machine key.
- <machineKey validationKey='C44B8B7C521CB5BC7E602BAE6118AA44CD690C7304817129DA27C17E800132A
-
1BD946C6D9AD12F0A5B342840C7D130564195428160B7466146938CA9E3A62686' decryptionKey='0E9DF2DA7F210B84087690FF0BF25C905182AD81E16A5FA9' validation='SHA1'/>
Session Configuration: Any web application is not possible without having
session as web pages are stateless so you can configure session in load
balancing also. There are two configuration which can be used in load balancing
environments. One is state service and another is Storing session in SQL Server.
Following is a good link to learn how you can configure sessions state in
asp.net application.
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0d9dc063-dc1a-46be-8e84-f05dbb402221.mspx?mfr=true
And here is a good link to configure session on SQL Server.
http://support.microsoft.com/kb/317604
You can configure session state mode in your web.config like following.
- <sessionState mode="SQLServer" StateConnectionString="tcpip=127.0.0.1:42424"
-
SqlConnectionString = "data source=SERVERNAME; user id=sa; password=sa"
-
cookieless="false" timeout="20" />
Caspol Utility: You can use caspol utility to share some resources on
between load balancing servers. Like we have file base cache dependency in our
application so we have created a central location(A shared folder for cache
files) for the both the server and used Caspol utility to give full trust share
on that folder for load balancing servers. Following are some of the good links
to which will teach how you can use CasPol utility to for asp.net application
http://blogs.msdn.com/shawnfa/archive/2004/12/30/344554.aspx
http://forums.asp.net/p/1119925/1881331.aspx#1881331
http://www.eggheadcafe.com/software/aspnet/30227544/caspol-addfulltrust.aspx
File Replication:File Replication is also an important features of
load balancing you should have replication enabled on the folders of web
application so if you upload anything on one server it should replicated to
other sites. Following is good link to understand file replication.
http://www.tgrmn.com/web/kb/item28.htm
Sticky Sessions: In some scenario Sticky session is very useful. In one page
our application we have used extensive Ajax and we need that for each request
and partial post back it should stay on one server till request completes.To
achieve that we can used sticky session. Following are some good links to know
about sticky sessions.
http://dev.fyicenter.com/Interview-Questions/JavaScript/What_does_the_term_sticky_session_mean_in_a_web_.html
http://blogs.msdn.com/drnick/archive/2007/07/13/sticky-sessions.aspx
Hope this will help you on deploying your asp.net on load balancing sites.
Following are some good links for understanding load balancing in more details
http://technet.microsoft.com/en-us/library/bb742455.aspx
http://support.microsoft.com/kb/323437
http://technet.microsoft.com/en-us/library/cc754833%28WS.10%29.aspx.
http://edge.technet.com/Media/Network-Load-Balancing-NLB-in-Windows-Server-2008/