我们推出了具有大流量的经典ASP.Net WebService应用程序。虽然我们的数据库运行良好(响应时间小于10毫秒),但在WebServer中花费的大部分时间都在MapRequestHandler阶段。
这个问题似乎在ASP .Net堆栈中很深,如果网上没有任何信息,我对如何改进它一无所知。
我们将XML有效负载用于请求/响应(如果这有助于提供解决方案)。
答案 0 :(得分:0)
请发布您的处理程序代码和您的配置文件。
<块引用>MapRequestHandler
- ASP.NET 基础结构使用 MapRequestHandler event
来确定
基于请求资源的文件扩展名的当前请求的请求处理程序。 MapRequestHandler
是处理程序需要实现的 event
,我怀疑它停留在映射某些自定义文件的某个委托上。
1
) 没有找到,循环找到那个自定义文件处理程序,你可能没有 2
) 使用 async handler
您必须追踪使用此 delegate
的各种 event
并设置断点
确保它们是 Async
和 Registered
,例如
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory" />
<add verb="*" path="*.config" type="System.Web.HttpForbiddenHandler" />
<add verb="*" path="*.asmx" type="System.Web.Services.Protocols.WebServiceHandlerFactory" />
然后在handlers下验证
<httpHandlers>
<add verb="*" path="*.MyCustomaspx" type="MyCustomHTTPhandler"/>
</httpHandlers>
在您的实现中使用 async
版本基本处理程序
// dervie from Async HttpTaskAsyncHandler
public class MyCustomHTTPhandler: HttpTaskAsyncHandler {
public override Task ProcessRequestAsync(HttpContext context)
{
//throw new NotImplementedException();
//blah blah.. some code
}
}
最后的手段,不推荐 - 从 SO here 开始,如果您的处理程序/页面没有修改会话变量,您可以跳过会话锁定。
<块引用><% @Page EnableSessionState="ReadOnly" %>
如果您的页面不读取任何会话变量,您可以为该页面选择完全退出此锁定。
<块引用><% @Page EnableSessionState="False" %>
如果您的页面都没有使用会话变量,只需在 web.config 中关闭会话状态即可。
<块引用><sessionState mode="Off" />
如果您想根据您的特定页面/处理程序自定义会话状态,则基于此
using System;
using System.Web;
public class CustomSessionStateModule : IHttpModule
{
public void Dispose(){ //.. }
public void Init(HttpApplication context){
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest(object sender, EventArgs e){
HttpContext currentContext = (sender as HttpApplication).Context;
// here you can filter and turn off/on the session state
if (!currentContext.Request.Url.ToString().Contains("My Custom Handler or Page Value")){
// for e.g. change it to read only
currentContext.SetSessionStateBehavior(
System.Web.SessionState.SessionStateBehavior.ReadOnly);
}
else {
//set it back to default
currentContext.SetSessionStateBehavior(
System.Web.SessionState.SessionStateBehavior.Default);
}
}
}