ASP.NET Request.Form Performance

前端 未结 3 1304
情深已故
情深已故 2020-12-29 12:13

I used a HttpHandler to implement a light-weight web service targeted for high performance. It requires a POST with content-type application

3条回答
  •  生来不讨喜
    2020-12-29 12:42

    Time delay occurs because IIS tries to read request stream from the client to retrieve form values. This stream is subject to client connection and in some causes will not even return. I have seen cases where Request.Form would block for over 5 minutes and it would cause IIS to eventually throw ThreadAbortException.

    In our case, we had an HttpModule that had to read through Request.Form values (or request["key"] which iterates over form values as well) and it would randomly block on the server and would never return. I used this HttpModule to track application performance on server side, which made me realize that anything I track using this module will also be dependent on client's connectivity, which would skew my server-side execution results.

    To resolve this issue, you can install reverse HTTP proxy in front of your application. Reverse proxy will off-load the responsibility of reading client stream (and blocking an expensive thread in your application) and send complete request to your server. This will reduce the load on your application, because you can save your precious application threads for dealing with your main workload rather than blocking them for reading from client streams.

    In addition, you can off-load HTTPs, load-balance, and even cache some static content on your reverse proxy (depending on which one you use).

提交回复
热议问题