简体   繁体   English

HttpModule的性能是否与RAMMFAR一样差?

[英]Does an HttpModule perform as badly as RAMMFAR?

I know that we're supposed to be careful about using RAMMFAR (runAllManagedModulesForAllRequests), such as the advice in this Hanselman post . 我知道我们应该谨慎使用RAMMFAR(runAllManagedModulesForAllRequests),例如Hanselman帖子中的建议。 The reason is that it sends all requests to every managed module. 原因是它将所有请求发送到每个受管模块。

But I recently had to create an HttpModule, and I noticed that it gets all requests anyway (because that's what a module is for), and now I'm wondering if there's any performance difference between setting RAMMFAR=true, and simply having a managed module, if that module is going to get all requests. 但是我最近不得不创建一个HttpModule,我注意到它无论如何都会获取所有请求(因为那是一个模块的目的),现在我想知道设置RAMMFAR = true与仅使用托管对象之间是否存在任何性能差异。模块,如果该模块将要获取所有请求。

To put this another way, are managed modules considered harmful to performance? 换句话说,托管模块是否被认为对性能有害? If I test the url and ignore requests I don't care about, will that hurt my scalability at all? 如果我测试url并忽略了我不关心的请求,那会不会损害我的可扩展性?

Edit : By all requests, I mean that I see requests for static content, such as css, js, and jpg files that are on disk. 编辑 :通过所有请求,我的意思是我看到对静态内容的请求,例如磁盘上的css,js和jpg文件。

Edit : The module is registered like this: 编辑 :该模块是这样注册的:

<modules>
  <add name="MyModule" type="MyNamespace.MyModule, MyAssembly"/>
</modules>

There are a few questions in your post. 您的帖子中有几个问题。 I'll try to address them individually. 我将尝试单独解决它们。

Does having a dummy (no-op) managed module impact performance / throughput? 具有虚拟(无操作)受管模块是否会影响性能/吞吐量?

Yes, from the perspective that IIS and ASP.NET need to coordinate the native <-> managed code transition, and this transition incurs some overhead. 是的,从IIS和ASP.NET需要协调本机<->托管代码转换的角度来看,这种转换会产生一些开销。 For the overwhelming majority of applications this overhead is dwarfed by the actual application logic. 对于绝大多数应用程序而言,实际的应用程序逻辑使这种开销显得微不足道。 The types of applications where this tends to show up in profiles are sites which are serving tens of thousands or hundreds of thousands of requests per second. 倾向于在配置文件中显示的应用程序类型是每秒处理数万或数十万个请求的站点。 At that point we generally recommend paying very close attention to which modules are included in the application and trimming them down as much as possible. 在这一点上,我们通常建议非常注意应用程序中包含哪些模块,并尽可能缩小它们的尺寸。

Why is my module running for static files? 为什么我的模块运行静态文件?

Because you don't have a managedHandler precondition on the module. 因为您在模块上没有ManagedHandler前提条件。 If this precondition is present on the module declaration, this module will only run if the request is destined for a managed endpoint (.aspx, .axd, extensionless, and so on). 如果模块声明中存在此前提条件,则只有在请求针对托管端点(.aspx,.axd,无扩展名等)的情况下,该模块才会运行。 If this precondition is not present, the module always runs. 如果不存在此前提条件,则模块始终运行。

To specify the managedHandler precondition: 要指定managedHandler前提条件:

<modules>
  <add name="..." type="..." preCondition="managedHandler" />
</modules>

Note: if you're on IIS 7.0 or 7.5, you might need to install the patch http://support.microsoft.com/kb/980368 to get IIS to see extensionless URLs as "managed" endpoints. 注意:如果您使用的是IIS 7.0或7.5,则可能需要安装修补程序http://support.microsoft.com/kb/980368,以使IIS将无扩展名的URL视为“托管”端点。

What does RAMMFAR actually do? RAMMFAR实际做什么?

In a nutshell, it ignores the precondition specified in the module registrations. 简而言之,它忽略了模块注册中指定的前提条件。 It does what its name implies: it runs all managedHandler modules for all requests, even if those requests weren't destined for a managed endpoint. 它的名称含义是:即使所有请求都不是针对托管端点的,它也会为所有请求运行所有managedHandler模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM