ASP.NET:如何并行请求进行处理 [英] ASP.NET: How parallel requests are processed

查看:261
本文介绍了ASP.NET:如何并行请求进行处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让的成像也有在网站上2页:快和慢。请慢页面是为1分钟执行,请求快速5秒。

我的整个职业生涯的发展我认为,如果第一次启动的要求是缓慢的:他会做一个(同步)调用DB ......等等答案......如果在此期间要求快速页面会做的,这个请求而系统正在等待来自DB响应进行处理。

但今天我发现:
<一href=\"http://msdn.microsoft.com/en-us/library/system.web.httpapplication.aspx\">http://msdn.microsoft.com/en-us/library/system.web.httpapplication.aspx


  

在HttpApplication类的一个实例来处理在其一生中的许多要求。然而,它可以处理在一个时间只有一个请求。因此,构件变量可以被用来存储每个请求的内容


这是不是意味着我原来的想法是错的?

能否请您澄清他们是什么意思?我是pretty肯定的事情是如我所料...


<类=h2_linDIV>解决方案

的请求都将在服务器端的顺序进行处理,如果都要求使用相同的会话状态,读/写访问,因为ASP的.NET会话锁定。

您可以在这里找到更多的信息:
http://msdn.microsoft.com/en-us/library/ie /ms178581.aspx


  

并发请求和会话状态


  
  

访问ASP.NET会话状态是每个会话,这意味着如果两个不同的用户进行并发请求,获得每个单独会话同时授予独占。但是,如果两个并发请求为同一会议上提出的(通过使用相同的SessionID值),第一个请求获取会话信息的独占访问。第二个请求的第一个请求完成后才能执行。 (如果因为第一个请求超出锁定超时的信息独占锁被释放的第二次会议,也可以访问)。如果在@ Page指令中的EnableSessionState值设置为只读,为只读的请求会话信息不会导致对会话数据的排他锁。但是,只读会话数据的请求仍然可能需要等待一个锁被读写请求会话数据清除设置。


Let's imaging there are 2 pages on the web site: quick and slow. Requests to slow page are executed for a 1 minute, request to quick 5 seconds.

Whole my development career I thought that if 1st started request is slow: he will do a (synchronous) call to DB... wait answer... If during this time request to quick page will be done, this request will be processed while system is waiting for response from DB.

But today I've found: http://msdn.microsoft.com/en-us/library/system.web.httpapplication.aspx

One instance of the HttpApplication class is used to process many requests in its lifetime. However, it can process only one request at a time. Thus, member variables can be used to store per-request data.

Does it mean that my original thoughts are wrong?

Could you please clarify what they mean? I am pretty sure that thing are as I expect...

解决方案

The requests have to be be processed in the sequential order on the server side if the both request use the same session state with read/write access, because of asp.net session locking.

You can find more information here: http://msdn.microsoft.com/en-us/library/ie/ms178581.aspx

Concurrent Requests and Session State

Access to ASP.NET session state is exclusive per session, which means that if two different users make concurrent requests, access to each separate session is granted concurrently. However, if two concurrent requests are made for the same session (by using the same SessionID value), the first request gets exclusive access to the session information. The second request executes only after the first request is finished. (The second session can also get access if the exclusive lock on the information is freed because the first request exceeds the lock time-out.) If the EnableSessionState value in the @ Page directive is set to ReadOnly, a request for the read-only session information does not result in an exclusive lock on the session data. However, read-only requests for session data might still have to wait for a lock set by a read-write request for session data to clear.

这篇关于ASP.NET:如何并行请求进行处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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