How to set up multi-server ASP. NET web applications and Web Services

Source: Internet
Author: User
Tags knowledge base server memory

This step-by-step article discusses how to set up
Multi-Server ASP. NET web applications and Web services. For most uses
ASP. NET, a single server can handle all requests in a timely manner. However,
Incluenvironments must deploy multiple servers to handle consistently high
Volumes of traffic, to support processor-intensive applications, to respond to sudden
Bursts in traffic, or to meet redundancy requirements.

In the simplest
Form, you can deploy web pages that consist only of Static HTML pages and
Images in a multi-server configuration by copying the files to multiple web
Servers and then loading ing a load balancing mechanic to distribute requests
Between the Web servers.

As the web site complexity increases, the difficulty of Synchronizing files and configurations between
Servers also increases. Dynamic sites require multiple servers to have access to a single
Database and to share state information among themselves. This article
Describes how to design multi-server ASP. NET solutions that include databases
And sessions.

Manage state

As a user navigates through an ASP. NET site, ASP. NET stores
Information about the user's session state. The exact information that is stored in
Session varies by application, but may include the user's name, preferences,
And shopping cart information.

By default, ASP. NET stores session information
In the server memory. This configuration is knownIn Process
. Although this configuration provides the best performance
Possible, you lose the session information if you restart the ASP. NET Server.
Additionally, in multi-server ubuntures, a single user's request can be
Sent to a different server. A user may start a session at one server, but later
Requests are sent to a different in-process server. This results in a new
Session being created for that user and all earlier information that was stored
In the session is lost.

ASP. NET provides two solutions for sharing
State information between multiple servers: the ASP. NET state Server service,
And Microsoft SQL Server. You can use either of these solutions to store state
Information between server restarts, and to allow users to move between servers during a single
Session.
For additional information, click
Following article numbers to view the articles in the Microsoft Knowledge Base:

317604
 

How to: Configure SQL Server
Store ASP. NET session state

815159
 
How to: analyze ASP. NET web application performance by using the performance administration toolsql session state

 

I found out the hard way that storing session in a SQL Server takes
Little more work then most of the books that I have read talk about.
Most articles don't talk about what settings you shoshould have when you
Are in a web farm. This article will hopefully point you in the right
Directions and keep you from the headaches that I had.

One of the first things to check is the easiest to fix. You will
Need to make sure you have a constant Machine Key between servers.
Machine key is used for encryption and decryption of cookie data.
Unless you set the machine key to a specific code on each machine they
Will use their own unique key, so when your connection switches from one
Server to the other server it can't decrypt the data and you lose your
Session.

Microsoft has a couple articles on their site on how to create
Machine keys and where to place them. You can place this machine key in
YourMachine. config
OrWeb. config
Files.

  • 312906
    How to: create keys by using Visual C #. net for use in Forms authentication
  • 313091
    How to: create keys by using Visual Basic. net for use in Forms authentication

The other fix is a little more complicated to change and is less
Likely to be a problem for everyone. This problem happens when you add
More websites to one server then to the other server then you try
Load Balance two websites. What happens is that the Application Path
For the websites is different on each server. For example on one server
You have a web with an Application Path// Lm/w3svc/2
And on the other server it has an Application Path// Lm/w3svc/4
.
The problem is IIS uses the Application Path to store the data, and if
They don't match you will lose your session. You will have
Synchronize the application path for the websites on all your web
Servers in the Web farm.

Microsoft has an article on this problem and how to fix it. If you think this is your problem please check out this article.

  • 325056
    PRB: session state is lost in Web farm if you use sqlserver or StateServer session Mode

When I was going through this we had both of these problems, and
After running though these steps we are now using SQL session state on
Our website, on a three Server Web farm.

Synchronize configuration and content

 

A Web site's security, performance, and other aspects of its
Behavior are defined by the configuration of the Web server. multi-server sites
Must have the configuration synchronized between all the servers to provide
Consistent experience to users whose requests are sent to different Web
Servers. ASP. NET makes it simple to synchronize Configuration between multiple
Servers because all configuration information is stored in the virtual
Server's path as XML files. These files have A. config file name extension.

You
Can copy configuration files to servers by using any standard file copy or
Synchronization method, including DFS, the file replication service, and
Microsoft Application Center 2000. The following batch file will work in
Environments where each web server has the virtual server root folder shared
Wwwroot $:

XCOPY //source-server/wwwroot$ //destination-server#/wwwroot$ /D /E /O /X

When you deploy configuration information and ASP. NET content
Multiple servers, it is critical to deploy the content from a single staging
Server to all production servers at the same time. This has CES the chance
Problems occurring when a user's requests are sent to different servers.
Microsoft recommends that all configuration and content updates occur on
Staging server. Ideally, this staging server does not receive requests from
Users. It is dedicated to the task of testing and deploying new
Content.

When you replicate updated. config files to a Web server,
That web application automatically restarts.

Note
If you put assemblies in the Global Assembly Cache, you cannot replicate them by using file synchronization.

Other tasks

Besides processing ing state management and content synchronization,
You must perform the following tasks to deploy
Multi-Server ASP. NET solution. These tasks are not specific to ASP. NET.

  • Request Distribution
    : Incoming HTTP requests must be distributed among all servers
    Using a mechanical such as round-robin DNS, Microsoft Application Center 2000,
    Or a third-party load distribution device.
  • Log Aggregation
    : Before you process HTTP usage logs, it is a good idea
    Combine the logs to create a single log that includes des requests sent to all
    Systems.
  • Monitoring
    : To detect problems that affect a single server or the whole
    Site, you must monitor both the external URL for the site and the URLs for each
    Of the Web servers.
  • Centralized database
    : Web applications that use a database must have a single database that is
    Shared between multiple Web servers. in environments that require no single
    Point of failure, cluster the database server.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.