Nipun Tomar
What is Web Gardening? How would using it affect a design?
By Nipun Tomar in ASP.NET on Jul 13 2006
  • Jul, 2006 21

    web garden:

    The process model helps enable scalability on multiprocessor computers by distributing the work to several processes, one per CPU, each with processor affinity set to its CPU. This eliminates cross-processor lock contention and is ideal for large SMP systems. This technique is called Web gardening. The configuration settings for enabling Web gardens are listed in the following table. Note that these settings take effect only after a server is restarted. IIS must be cycled in order for this change to take place.

    Setting Description :
    webGarden  Controls CPU affinity. True indicates that processes should be affinitized to the corresponding CPU. The default is False. 
    cpuMask  Controls the number of processes and how the Web garden works. One process is launched for each CPU where the corresponding bit in the mask set to 1. When UseCPUAffinity is set to 0, the cpuMask setting only controls the number of worker processes (number of bits set to 1). The maximum-allowed number of worker processes is the number of CPUs. By default, all CPUs are enabled; the same number of worker processes is launched as there are CPUs. The default value is 0xffffffff.

    Web gardening has some side effects that you should be aware of:
    If your application uses session state, it must choose an out-of-process provider (NT Service or SQL).
    Application state and application statics are per process, not per computer.
    Caching is per process, not per computer

    • 0
  • joby peter
    Jul, 2006 13

    1. The Web Garden Model: The Web garden model is configurable through the section of the machine.config file. Notice that the section is the only configuration section that cannot be placed in an application-specific web.config file. This means that the Web garden mode applies to all applications running on the machine. However, by using the node in the machine.config source, you can adapt machine-wide settings on a per-application basis.
    Two attributes in the section affect the Web garden model. They are webGarden and cpuMask. The webGarden attribute takes a Boolean value that indicates whether or not multiple worker processes (one per each affinitized CPU) have to be used. The attribute is set to false by default. The cpuMask attribute stores a DWORD value whose binary representation provides a bit mask for the CPUs that are eligible to run the ASP.NET worker process. The default value is -1 (0xFFFFFF), which means that all available CPUs can be used. The contents of the cpuMask attribute is ignored when the webGarden attribute is false. The cpuMask attribute also sets an upper bound to the number of copies of aspnet_wp.exe that are running.
    Web gardening enables multiple worker processes to run at the same time. However, you should note that all processes will have their own copy of application state, in-process session state, ASP.NET cache, static data, and all that is needed to run applications. When the Web garden mode is enabled, the ASP.NET ISAPI launches as many worker processes as there are CPUs, each a full clone of the next (and each affinitized with the corresponding CPU). To balance the workload, incoming requests are partitioned among running processes in a round-robin manner. Worker processes get recycled as in the single processor case. Note that ASP.NET inherits any CPU usage restriction from the operating system and doesn’t include any custom semantics for doing this.
    All in all, the Web garden model is not necessarily a big win for all applications. The more stateful applications are, the more they risk to pay in terms of real performance. Working data is stored in blocks of shared memory so that any changes entered by a process are immediately visible to others. However, for the time it takes to service a request, working data is copied in the context of the process. Each worker process, therefore, will handle its own copy of working data, and the more stateful the application, the higher the cost in performance. In this context, careful and savvy application benchmarking is an absolute must.
    Changes made to the section of the configuration file are effective only after IIS is restarted. In IIS 6, Web gardening parameters are stored in the IIS metabase; the webGarden and cpuMask attributes are ignored.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS