asp.netapplication-poolapplicationdomain

Difference between an application domain and an application pool?


What is difference between application domain and application pool?

I have read many articles regarding these two terminology. but still unable to get proper understanding about them.

Please elaborate it with simple description.

Thanks


Solution

  • IIS process is w3wp. Every application pool in IIS use its own process. AppPool1 uses process 3784, AppPool2 uses process 5044. Different applications in Asp.net will use different AppDomain.

    AppTest1 and AppTest2 are in different AppDomain, but in the same process.

    What's the point to use them?

    Application pool and AppDomain, both of them can provide isolations, but use different approaches. Application pool use the process to isolate the applications which works without .NET. But AppDomain is another isolation methods provided by .NET. If your server hosts thousands of web sites, you won't use thousands of Application Pools to isolate the web sites - too many processes running will kill the OS. However, sometime you need to use Application Pool isolation. One of the advantages for Application Pool is that you can configure the identity for Application Pool. Also you have more flexible options to recycle the Application Pool. At least right now, IIS doesn't provide explicit options to recycle the AppDomain.

    An Application Pool is a group of one or more URLs of different Web applications and Web sites. Any Web directory or virtual directory can be assigned to an Application Pool. Every application within an Application Pool shares the same worker process executable, w3wp.exe, the worker process that services one Application Pool is separated from the worker process that services another [Like starting MS Word and opening many word documents]. Each separate worker process provides a process boundary so that when an application is assigned to one Application Pool, problems in other Application Pools do not affect this application. This ensures that if a worker process fails, it does not affect the applications running in other Application Pools. E.g. if a Word document is having issue it should not logically affect your Excel sheet, isn’t it? Application domain is a mechanism (similar to a process in an operating system) used to isolate executed software applications from one another so that they do not affect each other. Much like how opening Word doesn’t affect Excel, and you can open and close both the applications any time since there is no dependency between the applications. Each application domain has its own virtual address space which scopes the resources for the application domain using that address space.

    Thanks to this link.