Getting an ASP.NET MVC web application to load domain neutral
Asked Answered
J

1

7

My company has a large number of clients and we are currently able to handle a limited number of clients per server. Every client, however, uses the same core web application. Currently some content is stored locally in every site therefore we can't have them using the same site/application pool; although we do have a multitenancy conversion project.

We strongly sign all of our assemblies and I thought it would be an interesting idea to see if we could get them to load domain neutral in ASP.NET. The advantage to this would be cutting our memory costs significantly which is one of our highest costs/limiting factors currently. In addition it seems that we would be able to streamline deployment processes which are currently [compilation] IO/CPU bound and cost us about 6 hours fairly often.

This task implies I want to move assemblies from loading in the App pool's app domain to the shared domain.

My understanding of the requirements for domain neutral loading are:

  1. The assembly must be strongly signed and in the GAC.
  2. The dependencies in the binding closure must be in the GAC [and strongly signed].

I've tried to get this to work, but I can't get it to work for a small sample application. I tried first putting Newstonsoft.Json into the GAC and to my excitement it flipped over to the shared domain after a recycle. However, I can't get any of the others to flip over to the shared domain even after GACing all of them:

enter image description here

My goal is to get my main application DLL to be loaded domain neutral. How can I debug/move forward on figuring out why the remaining Assemblies are not being loaded as domain neutral?

Additionally I'm a bit confused on how NGEN code page sharing relates or is in contrast to Shared Domain loaded assemblies.

Juggernaut answered 3/4, 2015 at 21:9 Comment(7)
have you tried looking at this post blogs.msdn.com/b/junfeng/archive/2004/08/05/208375.aspxIntermission
I am curious what your ultimate goal in this exercise is? Is it for performance or maintenance or something else?Mcmillen
@Mcmillen I noted most of it in the second paragraph. We are a growing company and have grown to have about 2,000 sites running on our system. Optimizing deployments and memory costs are very likely to be a high value return exercise. Those factors aside though....there is some lack in my understanding and I'd like to understand just what it is I don't yet understand.Juggernaut
I would think the memory savings on this type setup is not equal to the effort. There are many other factors that would give a lot more bang for the buck.Mcmillen
What specifically do you mean by wasting 6 hrs? You mean when you are updating the 2,000 applications?Mcmillen
Yes. Our full update release process takes on the order of six hours currently. We currently do this every other week, and it requires several people staffed to watch it, deal with issues, and follow up on production checks. I realize there are a lot of ways to skin that problem differently. We are currently memory bound as to the number of sites we can host per server, I also realize there are other ways to address this. I am exploring an idea, and trying to understand how .NET handles domain neutrality. It's likely just an educational endeavor, but if it works for a use case even better!Juggernaut
Yeah I suspect this will not solve your memory and io problems because each app will still have its own memory space and overhead. Also many things I read said there is over head to domain neutralMcmillen
T
1

Intern assemblies from ASP.NET 4.5 can be a solution. Look for the aspnet_intern command and the interndir argument.

Thanet answered 9/10, 2015 at 14:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.