简体   繁体   English

IIS是否同步处理请求?

[英]IIS serving requests synchronously?

I have a web site which I developed using C# and Visual Studio. 我有一个使用C#和Visual Studio开发的网站。

I noticed that in debug mode in visual studio(but with no break points) when I am on a page and pressing many times F5 to refresh the page, it takes a long time to serve all the requests till I get the last response to the browser. 我注意到在Visual Studio的调试模式下(但没有断点),当我在页面上并按多次F5键刷新页面时,要花很长时间才能处理所有请求,直到我得到对浏览器。 Meanwhile, when trying to access the site from a different browser session, I am waiting for a response from the server which is busy and doesn't respond. 同时,当尝试从其他浏览器会话访问站点时,我正在等待服务器繁忙的响应,但没有响应。

Doesn't IIS work asynchronously when serving requests to clients? 将请求提供给客户端时,IIS是否不异步工作?

Yes, IIS can serve multiple requests to clients in parallel, but if you are using session state in ASP.NET, then by default requests from a single session will be served sequentially (so that there's no possibility of two threads accessing the session state at the same time). 是的,IIS可以并行地向客户端提供多个请求,但是如果您在ASP.NET中使用会话状态,则默认情况下,单个会话的请求将按顺序提供(因此,不可能有两个线程在以下位置访问会话状态:同一时间)。

Your question is not clear if 'debug mode' means "with a debugger attached to the web server" or "when I compile my application with the 'debug' options" - if it's the former, then all bets are off as far as parallel operation is concerned - attaching a debugger almost always changes threading behaviour. 您的问题尚不清楚,如果“调试模式”的意思是“将调试器连接到Web服务器”还是“当我使用'debug'选项编译应用程序时”-如果是前者,那么所有赌注都尽可能地平行涉及到操作-附加调试器几乎总是会更改线程行为。

IIS and ASP.NET are heavily concurrent. IIS和ASP.NET是高度并发的。 Whether it runs requests from a single client concurrently is up to IIS etc. However, it isn't always possible to detect a disconnect - so if each request hammers the server, it could take a while to finish. 是否同时运行来自单个客户端的请求取决于IIS等。但是,并非总是能够检测到断开连接-因此,如果每个请求都对服务器产生冲击,则可能需要一段时间才能完成。 The tip there is: don't write slow pages. 这里的提示是:不要写慢的页面。 Set a target time that you want to respond within, and use a tool like mini-profiler to check how you are doing, and what is taking the time. 设置您要在其中响应的目标时间,并使用mini-profiler之类的工具检查您的工作状况以及所花费的时间。 Our target internally is about 30ms, but most folk will probably want to aim for 1s initially, then 0.5s, etc. 我们内部的目标是大约30毫秒,但大多数人可能最初希望将目标设为1秒,然后是0.5秒,依此类推。

When you are debugging and stopped at a breakpoint, all threads are frozen. 当您调试在断点处停止时,所有线程都被冻结。 Thus the other requests are queued up and waiting to be processed. 因此,其他请求排队等待处理。

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

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