Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A

QuestPond: Interview Questions and Answers on learning ASP.NET

What is the difference between “Web farmsWeb g” and “arden”?

“Web farms” are used to have some redundancy to minimize failures and to meet heavy load demands.

It consists of two or more web server of the same configuration and they stream the same kind of contents. When any request comes there is switching / routing logic, which decides which web server from the farm, handles the request. For instance, we have two servers “Server1” and “Server2” which have the same configuration and content. Therefore, there is a special switch, which stands in between these two servers and the users and routes the request accordingly.

rout 1

Above figure explains in detail how web farm work. You can see there is a router in between which takes a request and sees which one of the server is least loaded and forwards the request to that server. Therefore, for request1 it route is server1, for request2 it routes server2, for request3 it routes to server3 and final request4 is routed to server4. So you can see because we have web farm at place server1 and server2 are loaded with two request each rather than one server loading to full. One more advantage of using this kind of architecture is if one of the servers goes down we can still run with the other server thus having 24x7 uptime.

The routing logic can be a number of different options: -

  • Round robin: Each node gets a request sent to it “in turn”. Therefore, server1 gets a request, then server2 again, then server1, then server2 again.  As shown in the above figure.

  • Least Active: Whichever node show to have the lowest number of current connects gets new connects sent to it. This is good to help keep the load balanced between the server nodes.

  • Fastest Reply: Whichever node replies faster is the one that gets new requests. This is also a good option - especially if there are nodes that might not be “equal” in performance. If one performs better than the other, then send more requests there rather than which is moving slowly?

Before we try to understand what a web garden is let’s try to understand how IIS handles processes. All requests to IIS are routed to “aspnet_wp.exe” for IIS 5.0 and “w3wp.exe” for IIS 6.0. In normal case i.e. without web garden, we have one worker process instance (“aspnet_wp.exe” / “w3wp.exe”) across all requests. This one instance of worker process uses the CPU processor as directed by the operating system.

rout 2
However, when we enable web garden for a web server it creates different instances of the worker process and each of these worker process runs on different CPU. You can see in the below diagram we have different worker process instances created which run on different CPU’s.

rout 3
In short, we can define a model in which multiple processes run on multiple CPUs in a single server machine are termed as Web garden.

How do we configure “Web Garden”?

“Web garden” can be configured by using process model settings in “machine.config” or “Web.config” file. The configuration section is named and is shown in

The following example. The process model is enabled by default (enable=”true”). Below is the snippet from config file.

<process Model
idle Timeout=”infinite”
shutdown Timeout=”0:00:05"

From the above process model section for web garden, we are concerned with only two attributes “web garden” and “cpuMask”.

WebGarden: - Controls CPU affinity. True indicates that processes should be affinities to the corresponding CPU. The default is False.

CpuMask:- Specifies which processors on a multiprocessor server are eligible to run ASP.NET processes. The cpuMask value specifies a bit pattern that indicates the CPUs eligible to run ASP.NET threads. ASP.NET launches one worker process for each eligible CPU. If web Garden is set to false, cpuMask is ignored and only one worker process will run regardless of the number of processors in the machine. If web Garden is set to true, ASP.NET launches one worker process for each CPU that corresponds to a set bit in cpuMask. The default value of cpuMask is 0xffffffff.

Below are detail steps of how to implement web garden

  • Click Start and then click Run.

  • Type calc.exe and then click OK.

  • Go to View menu, click Scientific.

  • Go to View menu, click Binary.

  • Use zero and one to specify the processors ASP.NET can or cannot use.

Use one for the processor that you want to use for ASP.NET. Use 0 for the processor that you do not want to use for ASP.NET. For example, if you want to use the first two processors for ASP.NET of a four-processor computer, type 1100.

  • On the View menu, click Decimal. Note the decimal number.

  • Open the Web.config or machine.config file in a text editor such as Notepad. The Web.config file is located in the folder where the application is saved.

  • In the Web.config file, add the process Model configuration element under the System. Web element. Before adding <process Model> to Web.config file, the user has to make sure that the allow Definition attribute in the <process Model> section of the Web.config file is set to everywhere.

  • Add and then set the web Garden attribute of the process Model element to True.

  • Add and then set the cpuMask attribute of the process Model element to the result that is determined in your calculation.

Do not preface the number with zerox because the result of the calculation is a decimal number. The following example demonstrates the process Model element that is configured to enable only the first two processors of a four-processor computer.

cpuMask=”12" />

Save the Web.config file. The ASP.NET application automatically restarts and uses only the specified processors.

See following video on ASP.NET Web.config transformation:

If you want to learn or want more on ASP.NET learning then follow site
Tags: basics, interview questions, training, csharp interview questions, how to learn, it interview questions, programming interview questions, step by step, web farm, web garden

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded