gpt4 book ai didi

iis-7 - IIS7 模块 - 托管还是 native ?

转载 作者:行者123 更新时间:2023-12-01 11:08:51 25 4
gpt4 key购买 nike


由于旧的ISAPI过滤器迟早要消亡,我想将IIS 6中使用的旧ISAPI过滤器重写为IIS 7中使用的模块。该模块将在全局范围内使用,这意味着它将在每个站点中使用,在安装了 IIS 7.5 的 Windows Server 2008 R2 上,它将托管数千个网站并管理大约 50 个应用程序池。
我现在的问题是我应该用托管代码还是非托管代码编写该模块?我对托管代码的担忧之一是 .NET 框架开销导致的大量内存消耗。我不知道这将如何影响服务器的性能。
我已经用托管代码和非托管代码编写了模块。所以这不是困扰我的决定。但如果没有很大的缺点,我更愿意用 C# 编写模块。
关于这个问题有什么建议吗?

最佳答案

里克·斯特拉尔 offered sound advice关于这个主题,我在 learn.iis.net 的文章中看到了多次回应。

It’s also important to understand the potential for doing the wrong thing with all of this power. First keep in mind that managed code is slower than native code in the Web server. By introducing managed code into the core server you are slowing down the performance of the Web server. Specifically, the context switches between managed and unmanged code are expensive when running in Integrated Mode and with managed modules present. I’ve talked to some of the Microsoft developers, and they are taking a hard look at optimizing these context switches by trying to batch calls to managed code components as much as possible, staying in managed code as long as possible.

Managed code is optional by default-all the core modules are native code, so adding managed modules is an explicit decision you have to make. If you’re already using ASP.NET then this decision is probably a no-brainer. But if you’re running raw ISAPI extensions or modules today, you’ll probably have to take a long hard look to see whether managed code is going to be a good fit in terms of performance.

简而言之,如果所有应用程序都是 ASP.NET,那么为 IIS 编写托管模块的开销应该很少或没有开销 - 一个简单的选择。

但是,如果网站不会以其他方式加载 CLR,那么为了执行您的模块而这样做的成本将很高,您需要仔细考虑(衡量!)影响以确定性能损失是否值得开发时间生产力的提高。

关于iis-7 - IIS7 模块 - 托管还是 native ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2454719/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com