Lesson 5: Deploying Across Multiple Servers

Lesson 5: Deploying Across Multiple Servers

Web applications that serve a large number of users or that present large amounts of data need to able to add capacity as users demands increase. The ability to add capacity to an application is called scalability. ASP.NET Web applications support this concept through their ability to run in multiple processes and to have those processes distributed across multiple CPUs and/or multiple servers.

A Web application running on a single server that has multiple CPUs is called a Web garden in the ASP.NET documentation. A Web application running on multiple servers is called a Web farm. In this lesson, you ll learn how to enable your Web application to use each of these server configurations.

After this lesson, you will be able to

  • Configure a server with multiple processors to run a Web application on several or all of its CPUs

  • Run a Web application on multiple servers

  • Use a state server to share Session state information between multiple instances of the same Web application

  • Share Session state information using a SQL database

Estimated lesson time: 10 minutes

Scaling Up with Multiple Processors

If your server has multiple processors, you can specify that ASP.NET runs on all or some of the CPUs by setting the webGarden attribute of the processModel element in the server s Machine.config file, as shown here in boldface:

<processModel enable="true"  timeout="Infinite"  idleTimeout="Infinite"  shutdownTimeout="0:00:05"  requestLimit="Infinite"  requestQueueLimit="5000"  restartQueueLimit="10"  memoryLimit="60"   webGarden="true"  cpuMask="0xffffffff"  userName="machine"  password="AutoGenerate"  logLevel="Errors"  clientConnectedCheck="0:00:05"  comAuthenticationLevel="Connect"  comImpersonationLevel="Impersonate"  responseRestartDeadlockInterval="00:09:00"  responseDeadlockInterval="00:03:00"  maxWorkerThreads="25"  maxIoThreads="25" />

Table 9-6 describes the processModel attributes that relate to Web gardens.

Table 9-6. Web Garden Attributes

Attribute

Usage

webGarden

Set to true to run ASP.NET Web applications on more than one processor on this server.

cpuMask

Specifies which CPUs should run ASP.NET Web applications. The setting 0xffffffff runs the applications on all CPUs.

The cpuMask attribute is a bit mask used to turn ASP.NET on (1) or off (0) for each CPU on the server. For example, binary 1101 turns ASP.NET on for CPUs 0, 2, and 3 on a four-CPU server, leaving CPU 1 free for other uses. Binary 1101 maps to the hexadecimal setting 0x0000000d .

Running ASP.NET on multiple processors requires that you take special steps to handle Application and Session state information. See the section Sharing State Information, later in this lesson, for more information.

Scaling Up with Multiple Servers

For multiple servers to handle requests for a single HTTP address, you need to install load balancing to your network. Load-balancing services can be provided by hardware or software solutions.

Microsoft Windows 2000 Advanced Server and Microsoft Windows 2000 Datacenter both include Network Load Balancing (NLB) software to distribute requests to multiple servers. See the Visual Studio .NET online Help topic Network Load Balancing Provider for more information about installing and using this tool.

When load balancing is enabled for your network, you can install your Web application on multiple servers and have client requests distributed automatically to the least busy server at any given time.

Running a Web application on multiple servers requires that you take special steps to handle Application and Session state information. See the following section for more information.

Sharing State Information

In both a Web garden and a Web farm, client requests are directed to the ASP.NET process that is currently least busy. That means that a single client can interact with different CPUs or servers over the course of his or her session. This has the following implications for Application and Session state variables:

  • Application state variables are unique to each separate instance of the Web application.

    Clients can share information through Application state if the Web application is running on a Web garden or a Web farm.

  • Session state variables are stored in-process by default.

    To enable Session state in a Web garden or Web farm, you need to specify a Session state provider.

The following sections explore these issues in more detail.

Sharing Application State

To share data across multiple sessions in a Web garden or Web farm, you must save and restore the information using a resource that is available to all the processes. This can be done through an XML file, a database, or some other resource using the standard file or database access methods.

Sharing Session State

ASP.NET provides two built-in ways to share Session state information across a Web garden or Web farm. You can share Session state using:

  • A state server, as specified by a network location

    This technique is simple to implement and doesn t require you to install Microsoft SQL Server.

  • A SQL database, as specified by a SQL connection

    This technique provides the best performance for storing and retrieving state information.

To share Session state information using a state server, follow these steps:

  1. In the Web application s Web.config file, set the sessionState element s mode and stateConnectionString attributes. For example, the following settings use the state server located at the TCP/IP address 192.168.1.102 on port 42:

    <sessionState  mode="StateServer" stateConnectionString="tcpip=192.168.1.102:42" sqlConnectionString="data source=192.168.1.102;user id=sa;password=" cookieless="false"  timeout="20"  />

  2. Run the aspnet_state.exe utility on the Session state server. The aspnet_state.exe utility is installed in the \WINDOWS\Microsoft.NET \Framework\version folder when you install Visual Studio .NET Professional or Visual Studio .NET Enterprise Architect editions.

To share Session state information using a SQL database, follow these steps:

  1. In the Web application s Web.config file, set the sessionState element s mode and sqlConnectionString attributes. For example, the following settings use the SQL Server located at the TCP/IP address 192.168.1.102:

    <sessionState mode="SQLServer" stateConnectionString="tcpip=192.168.1.102:42"  sqlConnectionString="data source=192.168.1.102;user id=sa;password=" cookieless="false"  timeout="20"  />

  2. Run the InstallSqlState.sql utility on the Session state server. This utility installs the SQL database that shares Session state information across processes. The InstallSqlState.sql utility is installed in the \WINDOWS\Microsoft.NET \Framework\version folder when you install Visual Studio .NET Professional, Visual Studio .NET Enterprise Developer, or Visual Studio .NET Enterprise Architect editions.



MCAD(s)MCSD Self-Paced Training Kit(c) Developing Web Applications With Microsoft Visual Basic. Net and Microsoft V[.  .. ]0-315
MCAD(s)MCSD Self-Paced Training Kit(c) Developing Web Applications With Microsoft Visual Basic. Net and Microsoft V[. .. ]0-315
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 118

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net