HttpWebRequest and I/O completion ports

前端 未结 3 434
遥遥无期
遥遥无期 2021-01-02 23:27

I\'m working on an application that requires for one type of message to go hit a database, and the other type of message to go and hit some external xml api.

I have

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 00:24

    The way I understand it, you don't tie up an I/O completion port all the time that an asynchronous request is outstanding - it's only "busy" when data has been returned and is being processed on the corresponding thread. Hopefully you don't have very much work to do in the callback, which is why you don't have many in-use ports at any one time.

    Are you actually getting poor performance though? Is your cause for concern merely the low numbers? Are you getting the throughput you'd expect?

    One problem you may have is that the HTTP connection pool for any one host is relatively small. If you have hundreds of requests to the same machine, then by default only 2 requests will actually be made at a time, to avoid DoS-attacking the host in question (and to get the benefits of keep-alive). You can increase this programmatically or using app.config. Of course, this may not be an issue in your case, either because you've already fixed the problem or because all your requests are to different hosts. (If netstat is showing 2048 connections then that doesn't sound bad.)

提交回复
热议问题