Role of Web gardens and web farms in ASP.NET

Distributed applications that implement complex business processes face the challenge of providing high level of scalability and availability as the number of its users in the web become larger.

There are many cases, especially in a production kind of environment where there are millions of user hits that needs to be serviced by the web site. It is found better to address this issue at the stage of designing a distributed application rather than the stage of deployment. Web farms and web gardens are options that need to be considered while designing for scalability and availability features of such applications.

Web Farm

Web farm is a group of web servers having same software configuration and content but acting as a single virtual server with one TCP/IP address to clients. They service the clients by optimally sharing the internal resources and distribute the load equally amongst themselves. Web farm is built on the principle of Load Balancing.

Load balancing is a process in which the network packets are routed through a special switch to different web servers based on the options configured in it. The main function of the Load Balancer is to balance client requests between servers and optimize the wait time at the client side while utilizing the maximum use of server resources. The possible routing logic can be of the following types:

• Round robin: Each server node gets its turn cyclically so the request is processed equally within the servers
• Least Active: Server with least number of servicing requests will be given priority to process the incoming request
• Fastest reply: Server chosen for processing based on its efficiency in processing requests and hence optimum utilization of server with high performance is achieved

Web farms are typically used in server farms in enterprises which have backup servers that service requests in case of failure of the primary servers. These backup servers can be configured with replication systems so that duplicate data is always available. Also, Internet Service Providers(ISP) use this technology for providing web hosting services using multiple servers to provide better availability and performance. To handle peak load in normal server applications which are less mission-critical, a single domain with multiple servers and a database is used.

Advantages of Web Farm

• Better scalability by handling large capacity
• Provides availability and better performance due to load balancing
• Provides redundancy by reducing failures with the help of fault tolerance techniques
• Optimum utilization of resources that can be shared to service clients
• Good web site administration due to centralized monitoring of the web sessions

Web Garden

Web garden is a single web server executing server processes across multiple CPUs. Without Web garden, there will be only one worker process (w3wp.exe) executing in the CPU. This process executes all the requests that come to the server. With web garden, different instances of the worker process are created and executed in different CPUs. Hence, Web gardens provide better performance by avoiding the delay caused due to waiting for a worker process which is busy in processing a request.

Typically, web garden is better used in the following scenarios:

• when there is need to share resources and hence can cause contention of resources
• when the application is not very CPU intensive
• when there exists multiple instances of an application, each of which can be allocated a worker process

Advantages of Web Garden

• Increases application availability

• Optimum utilization of processes running on multiple processors located in a single server

• With the concept of Processor affinity (binding the application to processor with the help of CPU masks), applications can be swapped out and restarted on the fly

• Finer grained partitioning of Web servers help to control the administration of web sites individually, though they reside on the same server

• Less consumption of physical space with better capacity

Implementation of Web farm and Web garden in .Net

To implement web farm in .Net, following changes have to be made in web.config file:

Mode = [inproc/StateServer/SqlServer]

Option, inproc to be used when there is no web farm , StateServer when performance is required while SqlServer, if reliability is needed, especially for mission critical applications.

To implement web garden in .Net, following changes have to be made in web.config file:

• webGarden=[true]
Option, false used, if web garden is not necessary.
• cpuMask=8
Value for this section implies the decimal number, whose binary form represents the sequence of processors running processes on a multiprocessor server.

Best practices

• offers a facility to store the session info either in SQLServer database or in a separate State Service maintained in a separate machine and accessed by all servers

• Minimize the access to data store as much since the overhead caused here can bring down the performance enhancement seen due to effect of Load balancing

• In case of web farms, all the server machines in the cluster should be configured (in the web.config file of the application ) with same values for the sections mentioned below:


These are the sections that represent the cryptographic keys and authentication tickets for checking ViewState and User credentials of request to decode the sessionState of the client correctly. Hence, they need to be same so that any server can service any request from the client. This need not be done for a Web garden since all the worker processes are executed in the same server.

• While using Web Gardens, use Out-of-proc option for session state management. Do not use ‘In-proc’.

It is a good design practice to architect a system that is scalable from a single server to a web farm or web garden based scenario so as to leverage this clustering technology provided by .Net. It is a tough task to implement and is based on the budget allocated for developing the system as it involves both hardware and software.

|How to Define Custom Error Pages for Error Handling In ASP.Net Application| Role of Web gardens and web farms in ASP.NET | Understanding Purpose and Usage of "event" Class Member Modifier in C# (C Sharp) | Understanding the Structure and Content of Web.Config File | Usage of C# (C Sharp) Query Keywords – group, by, into | Usage of C# (C Sharp) Query Keywords – join, on, equals, let |Usage of C# (C Sharp) Query Keywords – orderby, ascending, descending | Usage of C# (C Sharp) Query Keywords – select, from, where, in | Usage of Lambda Operator (=>) in C# (C Sharp) |Using C# (C Sharp) as a tool for object oriented programming | Using Dictionaries in .Net – An Overview | Using WCF for providing web service |Hostinger Web Hosting India Review |


“Amazon and the Amazon logo are trademarks of, Inc. or its affiliates.”

| Privacy Policy for | Disclosure | Contact |

Copyright - © 2004 - 2024 - All Rights Reserved.