东西比HttpHandlers的快? [英] Something faster than HttpHandlers?

查看:105
本文介绍了东西比HttpHandlers的快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是一个ASP.NET网站上执行的方法,以最快的方式?

What is the fastest way to execute a method on an ASP.NET website?

该方案是pretty简单:我有当一个网页被击中应执行的方法。闲来无事是发生在页面上,唯一的渲染输出为完成的消息。我想的处理尽可能快

The scenario is pretty simple: I have a method which should be executed when a web page is hit. Nothing else is happening on the page, the only rendered output is a "done" message. I want the processing to be as fast as possible.

每一个命中是唯一的,所以缓存是不是一种选择。

Every single hit is unique, so caching is not an option.

我的计划是使用一个HttpHandler,并在web.config中(mypage.ashx)配置,而不​​是常规的.aspx页。这应该显著减少开销。

My plan is to use an HttpHandler and configure it in web.config (mypage.ashx) rather than a regular .aspx page. This should reduce the overhead significantly.

所以我的问题是真的?有没有做到这一点比使用更快的方法HttpHandlers的

So my question is really: Is there a faster way to accomplish this than using HttpHandlers?

推荐答案

根据你在做什么,我不希望看到一个很大的改进仅仅使用一个HttpHandler过来。我只需写的HttpHandler,看它如何执行启动。如果你需要它要快,尽量在你实际做处理请求时,看到有什么可以优化的东西更密切关注。例如,如果你做的任何记录到数据库中,尝试写到本地数据库,而不是在网络上。如果它仍然不够快,那么也许看看写东西较低水平。直到这一点,虽然,我与任何最简单的方法为你写贴。

Depending on what you're doing, I wouldn't expect to see a lot of improvement over just using an HttpHandler. I'd start by just writing the HttpHandler and seeing how it performs. If you need it to be faster, try looking more closely at the things you're actually doing while processing the request and seeing what can be optimized. For example, if you're doing any logging to a database, try writing to a local database instead of across a network. If it's still not fast enough, then maybe look into writing something lower level. Until that point though, I'd stick with whatever's easiest for you to write.

有关参考,我在负载下0-15ms用ASP.NET编写的广告服务器(使用HttpHandlers的),可以投放广告(包括定位和记录的IM pression到本地数据库)。我想我是做了不少的处理 - 但是这是一个pretty良好的响应时间恕我直言

For reference, I've written an ad server in ASP.NET (using HttpHandlers) that can serve an ad (including targeting and logging the impression to a local database) in 0-15ms under load. I thought I was doing quite a bit of processing - but that's a pretty good response time IMHO.


更新后的数个月

如果由默认包含你清除所有的HttpModules,这将删除的开销相当数量。默认情况下,下面的HttpModules被包含在通过计算机级别的web.config文件中的每一个网站:

If you clear all the HttpModules that are included by default, this will remove a fair amount of overhead. By default, the following HttpModules are included in every site via the machine-level web.config file:


  • 的OutputCache

  • 会话(会话状态)

  • WindowsAuthentication

  • FormsAuthentication

  • PassportAuthentication

  • RoleManager

  • UrlAuthorization

  • FileAuthorization

  • AnonymousIdentification

  • 简介

  • 的ErrorHandler

  • ServiceModel

就像我上面说的,我的广告服务器不使用任何这些,所以我只是做到了这一点在该应用的web.config:

Like I said above, my ad server doesn't use any of these, so I've just done this in that app's web.config:

<httpModules>
   <clear />
</httpModules>

如果你需要其中的一些,但不是全部,你可以删除那些你不需要

If you need some of those, but not all, you can remove the ones you don't need:

<httpModules>
   <remove name="PassportAuthentication" />
   <remove name="Session" />
</httpModules>

ASP.NET MVC注意: ASP.NET MVC需要会话状态模块,除非你做具体要解决它的东西。更多信息请参见这个问题:<一href=\"http://stackoverflow.com/questions/884852/how-can-i-disable-session-state-in-asp-net-mvc\">http://stackoverflow.com/questions/884852/how-can-i-disable-session-state-in-asp-net-mvc

ASP.NET MVC Note: ASP.NET MVC requires the session state module unless you do something specific to workaround it. See this question for more information: http://stackoverflow.com/questions/884852/how-can-i-disable-session-state-in-asp-net-mvc

IIS7的更新:不幸的是,事情并不在IIS7一样简单。这里是<一个href=\"http://serverfault.com/questions/72338/iis7-lock-violation-error-http-handlers-modules-and-the-clear-element\">how清除HTTP模块在IIS7

Update for IIS7: Unfortunately, things aren't quite as simple in IIS7. Here is how to clear HTTP Modules in IIS7

这篇关于东西比HttpHandlers的快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆