Web Server – Web Farm – Web Garden

As I was going through some articles on Scott Hanselman’s blog, I found this interesting post about interview questions for senior software engineer. I thought it will be worth to write a small post on one of the question in the list – what is the difference between Web Server, Web Farm and Web Garden?

I would try to explain this keeping in mind that you have very basic understanding of Application Pool, ASP.Net worker process [W3WP.EXE], though I explained it in short below.

Web Server – It is a component which is used to host web application on a centralized location to which multiple clients can send the requests in parallel. To test and run ASP.Net web application, you need at least one web server. Visual Studio .Net IDE provides built-in web server called ASP.Net Development Server, which can be used during application development. Microsoft Windows operating system includes Internet Information Services [IIS] component, which provides web server for ASP.Net applications. IIS contains ASP.Net process engine / worker process [W3WP.EXE] which processes client requests and sends response back to clients.

Below diagram shows that client machine sends request to IIS on server machine over internet. ASP.Net worker process on IIS processes this request, generates the response and sends it back to the client. Note that, single IIS server can serve multiple clients, but it may impact request processing performance. In that case you may need multiple servers to host the application and divide the incoming traffic amongst them, which is known as Web Farm.

Web Server Processing Client Request

Web Server Processing Client Request

Advantages

  1. Suitable architecture for small web applications with less network traffic.
  2. No additional hardware cost as IIS is hosted on single server.
  3. Session data can be stored using In Proc or Out of Proc mode.

Disadvantages

  1. Single IIS server may not be sufficient to process large number of client requests in parallel.
  2. Application may become unavailable if server goes down, as it is single server architecture.
  3. Not scalable.

Web Farm – In general, web farm is a collection of web servers maintained by enterprise to process multiple client requests efficiently which are far beyond single web server capability. In this architecture, single application is hosted on multiple servers which are connected with each other using Load Balancer. These servers need to have same operating system and patches. Load balancer accepts the client request and distributes it to appropriate web server. Normally, load balancers are configured using round-robin algorithm i.e. first request gets routed to Web Server 1, second to Web Server 2 and so on.

Below diagram depicts web farm architecture.

Web Farm Architecture

Web Farm Architecture

Advantages

  1. Makes application highly available. If anyone server goes down, load balancer can still redirect incoming requests to other active server.
  2. Client requests can be processed efficiently as load is distributed across multiple servers.
  3. Provides better scalability as additional servers can be added easily, which reduces application failure and increases application availability.

Disadvantages

  1. Additional hardware cost as it requires minimum two servers.
  2. All session data will be lost if ASP.Net worker process recycles, so In Proc session mode is not suitable for this architecture. In statefull application this architecture may have another performance penalty to serialize the state to an external store.

Web Garden– ASP.Net worker process is heart of IIS. When client sends a request to IIS, worker process is responsible for processing this request, generating appropriate response, persisting data in session or cache etc. Each worker process is isolated in an application pool, which enables better security, reliability for web applications.

Below is the pictorial representation of Application Pool and Worker Process.

Application Pool

Application Pool

By default each application pool contains single worker process. In an architecture, where application pool contains multiple worker processes, known as Web Garden.

Web Garden Architecture

Web Garden Architecture

Advantages

  1. Makes application highly available. If any one server goes down, load balancer can still redirect incoming request to other active server.
  2. Client requests can be processed efficiently as load is distributed across multiple servers.
  3. Provides better scalability as additional servers can be added easily, which reduces application failure and increases application availability.
  4. Since all the worker processes within same application pool shares the incoming client request, if any worker process fails, another worker process can continue to process same request. This provides better throughput performance and application response time.

Disadvantages

  1. Additional hardware cost as it requires minimum two servers.
  2. All session data will be lost if worker process recycles, so In Proc session mode is not suitable for this architecture. In statefull application you have another performance penalty to serialize the state to an external store.

Hope this article was useful to you.

Thanks.

2 Comments

  1. Vaidya Srihari · November 18, 2013 Reply

    There is a confusion, whether the “web garden” architechture can be set on single server or not.

    If we can, then the advantages of “web garden” should be redefined for multiple processor instead of “Multiple Servers”.

    Please clarify on this.

    • Prasad Honrao · November 18, 2013 Reply

      Srihari – You can surely setup multiple worker processes on a single server. Main difference between Web Farm and Web Garden is number of worker processes running in an application pool. In case of Web Farm, its default to 1, and if you set it to more than 1 worker process, it becomes Web Garden. Hope this helps.

Leave a Reply