0

I'm from C background, for a concurrent server written by C, when there is a new incoming request, the server program either spawns a new child process or a new thread to service the client. So if there are 10 users requests the index.html page at the same time, it could be 10 child processes generated on the server side, or 10 worker thread are used if the server is based on pre-threading worker thread pool.

But for asp.net web application(let's talk about asp.net not asp.net core who doesn't use Appdomain), below is my question:

Q1-IIS that hosts application will create a new Appdomain for the asp.net web application, but will a new Appdomain created to handle a new request? so if there are 10 requests then there will be 10 Appdomains being created? If not, how does IIS handle concurrent requests from multiple users?

Q2- What's the relationship between Appdomain and the worker thread in the CLR thread pool? does a new worker thread is used to run the application in the new Appdomain?

amjad
  • 3,048
  • 1
  • 11
  • 42
  • Not an answer, but you can find the ASP.NET code [here](https://github.com/aspnet/AspNetWebStack). – DiplomacyNotWar Jan 18 '21 at 03:35
  • Q1: There are probably ten `HttpApplication` derived objects, but not ten `AppDomain` objects because a single one is there for each IIS applications. To learn what's that please use a search engine or find a good book. Q2: There is no direct relationship between `AppDomain` and worker threads, but each `HttpApplication` runs on a dedicated worker threads. – Lex Li Jan 18 '21 at 03:45
  • `so if there are 10 requests then there will be 10 Appdomains being created?` No. Appdomains are reasonably expensive, so not appropriate for this context. – mjwills Jan 18 '21 at 03:46
  • `a single one is there for each IIS applications.` @LexLi - also keep in mind web gardens. – mjwills Jan 18 '21 at 03:48
  • 1
    @amjad The short answer is that there is a pool of threads used to service requests. – mjwills Jan 18 '21 at 03:48
  • @mjwills so the benefits usage of appdomain is, e.g. a web design company can put all its clients' applications in different appdomain in IIS by using only one OS process, is my understanding correct? – amjad Jan 18 '21 at 03:54
  • @amjad What you described is just a horrible usage. Putting too many things in a single process only makes it difficult to free up memory and layout objects, and usually leads to poor performance. Application domains were primarily introduced to serve ASP.NET application isolations as you learned, but it didn't really offer many benefits and therefore removed in .NET Core (.NET Core only allows a single app domain). – Lex Li Jan 18 '21 at 06:31

0 Answers0