I have been asked this question many times by different readers of my blog. They wanted to know about the fundamentals of Web Farms and Web Garden. In this blog post, I am going to explain the what is the exact difference between web farm and web garden, what are the advantages and disadvantages of using them. I have also described how to create web garden in the different version of IIS.
Visual Studio is having its integrated ASP.NET engine which is used to run the ASP.NET Web application from Visual Studio. ASP.NET Development Server is responsible for executing all the request and response from the client. Now after the end of development, when you want to host the site on some server to allow other peoples to access, the concept of web servers comes in between. A web server is responsible for responding to all the requests that are coming from clients. Below diagram showing the typical deployment structure of an ASP.NET Web application with a single IIS.
Clients request for resources and IIS Process the request and send back to clients. If you want to know more details on How IIS Process the request, please read one of my article over “How IIS Process ASP.NET Request ?”.
Web Farm :
This is the case, where you have only one web server and multiple clients requesting for the resources from the same server. But when there are huge numbers of incoming traffic for your web sites, one standalone server is not sufficient to process the request. You may need to use multiple servers to host the application and divide the traffic among them. This is called “Web Farm.” So when you are hosting your single web site on multiple web server over load balancer called “Web Farm.” Below diagram showing the over all representation of Web Farms.
In general web farm architecture, a single application is hosted on multiple IIS Server, and those are connected with the VIP ( Virtual IP ) with Load Balancer. Load Balancer IP’s exposed to external worlds to access. So whenever some request comes to the server from clients, it will first hit the Load Balancer, then based on the traffic on each server LB distributed the request to corresponding web server. These web server may share same DB server or may be they can use replicated server in the back end.
So, In a single statement, When we host a web application over multiple web server to distribute the load among them is called Web Farm.
Web Garden :
Now, let’s have a look, what is Web Garden? Both the terms sound same, but they are different with each other. Before starting with Web Garden, I hope you have a fundamental idea of what is Application Pool and what is Worker Process. In case you are not clear about the concept Application Pool and Worker Process, I would highly recommend reading the article: “How IIS Process ASP.NET Request ?”.
Just to recall, When we are talking about requesting processing with in IIS, Worker Process (w3wp.exe ) takes care all of these. Worker Process runs the ASP.Net application in IIS. All the ASP.Net functionality inside IIS runs under the scope of the worker process. Worker Process is responsible for handling all kind of request, response, session data, cache data. Application Pool is the container of the worker process. Application pools are used to separate sets of IIS worker processes and enable a better security, reliability, and availability for any web application.
Now, by default, every Application pool contains a single worker process. The application which contains the multiple worker processes called “Web Garden”. Below is the typical diagram for a web garden application.
In the above diagram, you can see, on of the application containing the multiple worker processes, which is now a web garden.
So, a Web application hosted on multiple server and access based on the load on servers is called Web Farms and When a single Application pool contains multiple Worker processes is called web garden.
Create Web Garden in IIS 6 and IIS 7
Now, I am going to show how you can change the Number of Worker process In both IIS 6 and IIS 7. For IIS 6, Right Click on Application Pool > Properties > Go to Performance Tab.
In the “Performance Tab” Section you would have one option called “Web Garden” where worker process sets to “1”, you can set the number of worker process that you required.
For IIS 7, Right Click on Application Pool > Go To Advance Settings > In Process Model section, you will have “Maximum Worker Processes” . You can change it more than 1 to make it as web garden.
In the above image you can also check the definition of Web Garden also.
You can find one of my previous article on the basic of same over here
Advantages of Web Farm and Web Garden :
Now, let’s have a look in to the advantages of both the Web farms and Web Garden.
Advantages of Web Farm
- It provides high availability. If any of the server in the farm goes down, the Load balancer can redirect the requests to other servers
- Provides high-performance response for client requests
- Provides Better scalability of the web application and reduce the failure of an application
- Session and another resource can be stored in a centralized location to access all server
Advantages of Web Garden:
- Provides better application availability by sharing request between multiple worker processes
- Web garden use processor affinity where an application can swap out based on preference
- Less consumption of physical space for web garden configuration
How to manage session in Web Farm Mode ?
While using session, requests are distributed among different servers. By default session mode is set to In Proc where session data stored in worker process memory. But, In Web farm way we can share the session among all the server using a single session store location my making it Out proc (State Server or SQL Server Mode). So, if some of the servers go down and request transferred to the other server by the Load balancer session data should be available for that request.
In the above diagram, you can see we can both the IIS server sharing the same session data which is stored in out of worker process. You can read one of my previous article “Exploring Session in ASP.NET” where I have explained how you can configure session mode for Out Process mode.
How to manage session in Web Garden Mode ?
When we are using Web garden where the request is taking care of different worker process we have to make the session mode as out process session mode as described earlier. For Web Garden, we have configured the out process with on the same server but for the different worker process.
While using Web garden with your application, you need do a couple of configuration settings in web.config in <process Model> section where you need to set certain properties like cpuMask, RequestLimit, webGarden, ClientConnectCheck etc.
When we host a web application over multiple web server to distribute the load among them is called Web Farm and when one application is having multiple worker process called Web garden.
In this blog post, I have explained the very basics of what Web Farm is and what Web Garden is. As this blog post contains the necessary information to understand the fundamentals of web farms and web garden concept, I will be posting a separate article with details configuration setting for web garden and web farm. You can read those below articles for more information
Hope this will help you.