Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do websites in the same application pool share loaded libraries?

I have a Windows Server 2012 with IIS 8.0. It is hosting many small websites with a low user base which are not mission critical in any way. With small website I mean that the application code and memory footprint is quite low, but due to the loaded libraries, like EntityFramework, the memory consumption of the applications are about 140MB when freshly started and idle.

In general that’s not a big deal for a full-blown webserver, but I only have a VPS with 4GB of RAM which also runs several other applications (databases, BIND, hMail, etc.). I’m using it basically as development server to play with many different technologies. Therefore, I’m running out of RAM quickly while serving dozens of ~140MB w3wp’s.

Beside of suspending when idle I’d like to reduce the memory consumption while still using any framework or library I’d like to use – that’s the purpose of the whole thing actually.

Long story short: As the applications not only share the same .NET version but also some libraries like EF or MVC, would it make more sense to run multiple sites in one app_pool so that they can share the libs? Or would each site load its own copy anyway (due to different Application domains like discussed here)?

Bonus question: when considering a hardware upgrade 1GB of RAM is 20$/month but putting the whole server on SSDs is 10$/month. While I do know that reading from page file is always much slower than reading from RAM I’m thinking about using a big pagefile on the SSD instead of buying 1gig of additional RAM for twice the price – again, speed of the websites isn’t critical, they should just work. Would that make any sense at all?

like image 493
marce Avatar asked Dec 24 '13 12:12

marce


1 Answers

Looking at a w3wp Process (hosting multiple sites) in Process Explorer shows that it hosts several different application domains with different instances of the same assemblies loaded into memory. So moving the sites into a single AppPool may not help much.

But there is another option. In IIS 8+ you can share common assemblies across AppPools. If certain assemblies are used by multiple AppPools, they are loaded into memory just once and then aliased by the different processes.

Have a look at this bit from asp.net and this TechNet blog post

You have to do a little bit of setup work, but then it seems to work quite well.

like image 105
Peter Hahndorf Avatar answered Oct 23 '22 05:10

Peter Hahndorf