HttpWebRequest and I/O completion ports

前端 未结 3 400
遥遥无期
遥遥无期 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:13

    Having only 9 completion port threads actually means you're probably using them correctly and efficiently. I'm going to assume that the machine you're running on has either 8 cores or 4 hyperthreaded cores which means that the OS will try to keep up to 8 active (not sleeping/blocking/waiting) completion port threads at any time.

    If one of the running threads becomes inactive (sleep/block/wait) and there are additional work items to process, then an additional thread will be created to keep the active count at 8. If you see 9 threads, that means that you are introducing virtually no blocking in the methods on your completion port threads and actually doing CPU work with them.

    If you have 8 threads actively doing CPU bound work on 8 cores, then adding more threads will only slow things down (context switching between threads will be the wasted time).

    What you should be looking in to is why you have 120 other threads and what those are doing.

提交回复
热议问题