gpt4 book ai didi

ASP.NET:如何处理并行请求

转载 作者:行者123 更新时间:2023-12-01 14:45:55 25 4
gpt4 key购买 nike

让我们想象一下网站上有 2 个页面:快速和慢速。请求慢速页面执行 1 分钟,请求快速页面 5 秒。

在我的整个开发生涯中,我认为如果第一个开始的请求很慢:他将对 DB 进行(同步)调用...等待回答...如果在此期间完成对快速页面的请求,则该请求将被处理,而系统正在等待来自 DB 的响应。

但是今天我发现:
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.



是不是说我原来的想法是错误的?

你能澄清一下他们的意思吗?我很确定事情正如我所料......

最佳答案

如果两个请求使用具有读/写访问权限的相同 session 状态,则必须在服务器端按顺序处理请求,因为 ASP.NET session 锁定。

您可以在这里找到更多信息:
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:如何处理并行请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3988523/

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