Tuesday, June 23, 2009

Web Farm Vs Web Gardening

Web Farm:

A web farm is a multi-server scenario. A Web farm allows you to expand a Web Site across multiple servers. E.g., we may have a server in each state of US. If the load on one server is in excess then the other servers step in to bear the brunt. The main reason behind the scene is to distribute the load over the multiple server. Load balancer is used to distribute the load on those server.

It can based on various models:

1. RoundRobin. (All servers share load equally)
2. NLB (economical)
3. HLB (expensive but can scale up to 8192 servers)
4. Hybrid (of 2 and 3).
5. CLB (Component load balancer).

Web Garden:

By default Each Application Pool runs with a Single Worker Process (W3Wp.exe). We can Assign multiple Worker Process With a Single Application Pool. An Application Poll with multiple Worker process is called Web Garden. Many worker processes with same Application Pool can sometimes provide better throughput performance and application response time.

A Web garden allows you to expand a Web Site across multiple CPUs within a single server. So a web garden is a multi-processor setup. i.e., a single server. In a Web garden, HTTP.sys distributes the requests among the set of worker processes in the application pool.

It can based on various models:

1. inproc (non web farm but fast when you have very few customers).
2. StateServer (for webfarm)
3. SqlServer (for webfarm)

Creating a Web garden for an application pool can also enhance performance in the following situations:

-> Robust processing of requests: When a worker process in an application pool is tied up (for example, when a script engine stops responding), other worker processes can accept and process requests for the application pool.

-> Reduced contention for resources: When a Web garden reaches a steady state, each new TCP/IP connection is assigned, according to a round-robin scheme, to a worker process in the Web garden. This helps smooth out workloads and reduce contention for resources that are bound to a worker process.

Note: There are some Certain Restriction to use Web Garden with your web application. If we use Session Mode to "in proc", our application will not work correctly because session will be handled by different Worker Process. For Avoid this Type of problem we should have to use Session Mode "out proc" and we can use "Session State Server" or "SQL-Server Session State".

More details: InProc is handled by Worker Process. Its keeps data insides its memory object. Now if we have multiple Worker Process, then it would be very difficult to handled the session because, each and every Worker process has it own memory, so if the first request goes to WP1 and its keep the session data and Second Request goes to WP2 and when we try to retrieve session data, it will not able to return . Which will throw error. So we should always avoid Web Garden in InProc Session Mode.

0 comments: