The server Load balancer device allows you to easily expand a web server to a Web server cluster (provided that all Web servers must be configured completely the same, the device will send the request accordingAlgorithmTo a server in the web server cluster, which greatly increases the concurrent processing capability of the Web server.
In practical applications, multiple Web servers are usually deployed in the same data center and can be accessed from each other through a LAN.
1. file synchronization problems:
The website files on multiple Web servers must be identical. Otherwise, the content of pages accessed by the user's two requests may be different. Therefore, file synchronization is the primary concern.
Several common methods are introduced here:
A.Batch files + scheduled tasks: batch files use the DOS command to copy files in the LAN, and then the BAT files are automatically executed at a certain time in the scheduled task.
This method is suitable for application environments that are not updated frequently. If file updates are required to be updated in real time, this method will not work.
B.Using ready-made file sync software: there are some good file sync software available on the market, just use it directly. (Some powerful software supports two modes: timed synchronization and real-time synchronization)
C.If you want to DIY, you can actually use it. in. net, the filewatcher class can conveniently implement file synchronization by monitoring files in the source site directory. In addition, this method is flexible and can be implemented in real time or at regular intervals (completely controlled by developers ).
For examples of filewatcher usage, see my other blog: http://www.cnblogs.com/yjmyzz/archive/2009/06/07/1498221.html (using filewatcher for real-time file Monitoring)
2. Session Processing
By default, session is in inproc mode, that is, session is stored on the server where the website is located, so session synchronization on multiple servers is also a problem. This ASP era may be troublesome, but fortunately. net starts from 2.0 and allows sessions to be stored on a specific server or even a database. No matter how many web servers are there, all sessions can be stored in a dedicated database server.
The following describes how to use SQL Server as an example:
A.Stop IIS service first, enter net stop W3SVC or iisreset/stop in cmd environment (this step looks optional, see http://support.microsoft.com/kb/317604 for details)
B.Open the database and run \ winnt \ Microsoft. NET \ framework \ (. NET version) \ installsqlstate. SQL to configure the session database.
C.Modify the Web. config configuration of the website as follows:
<Sessionstate mode = "sqlserver" sqlconnectionstring = "Data Source = Server IP address; user id = ***; Password = ***; "cookieless =" false "timeout =" 20 "/>