Does a worker process share its output cache within an AppPool?

天大地大妈咪最大 提交于 2019-12-02 13:01:27

问题


Summary:

I have an ASP.NET MVC website in IIS named 'Website' using an AppPool named 'WebsiteAppPool'. WebsiteAppPool is configured to allow up to 4 Worker Processes, in effect creating a 'Web Garden'. The Website is also configured, via web.config, to enable OutputCaching using CacheProfiles.

<caching>
  <outputCacheSettings>
    <outputCacheProfiles>
      <clear />
      <add name="ControllerNameActionName" duration="43200" varyByParam="*" />
    </outputCacheProfiles>
  </outputCacheSettings>
</caching>

My question is -

Will the AppPool's worker process' share the output cache or will each worker process have the Output Cache, therefore creating 4 cached copies across the AppPool.

Note:

My main concern is that this will debunk the benefits of having cached output and I would be better off having one WorkerProcess serving up the cached output rather than the 4.


回答1:


From MSDN:

Because Web gardens enable the use of multiple processes, each process will have its own copy of application state, in-process session state, caches, and static data. Web gardens should not be used for all applications, especially if they need to maintain state. Be sure to benchmark the performance of the application before deciding whether Web garden mode is appropriate.

When using a Web garden, it is important to understand how session state and round robin works. It is also important to consider of how other application pool settings affect the application

Web gardens are especially screwy if you're doing in-process session state (which you hopefully aren't anyway). In my experience, I find that web gardens are rarely the benefit that people think they are.




回答2:


There is no relation between the worker processes. They each have their own cache (as it is in-process cache). That said, if you make your application support the web-garden scenario (i.e. not depend on in-process state) it will be more robust and easier to scale up. It will be easier to add another server in the future and create a web-farm.

You might call YAGNI on that, but I think it is just common sense to create most web-applications in a way that supports scaling up. In your case, I really think it's OK to have 4 different caches, and having a web garden can actually improve your site's performance.



来源:https://stackoverflow.com/questions/1894212/does-a-worker-process-share-its-output-cache-within-an-apppool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!