zoukankan      html  css  js  c++  java
  • ThreadPool growth related important details

    ThreadPool growth related important details
    When CLR loaded into a process, it creates a ThreadPool. Each CLR has its own ThreadPool which shares between all AppDomains within the CLR. The ThreadPool provides two types of threads: Worker and I/O Completion Port(IOCP).
    Worker threads are used for things like processing the Task.Run(...) or ThreadPool.QueueUserWorkItem(...) methods.
    IOCP threads are used when asynchronous IO happens, such as when reading from the network.

    The thread pool provides new worker or I/O completion threads on demand(without any throttling) until it reaches the "Minimum" setting for each type of thread. By Default, the minimum number of threads is set to the number of processors on a system.

    Once the number of existing(busy) threads hits the "minimum" number of threads, the ThreadPool will throttle the rate at which it injects new threads to one thread per 500 ms.

    Typically, if your system gets a burst of work needing an IOCP thread, it will process that work quickly. However, if the burst of work is more than the configured "Minimum" setting, there will be some delay in processing some of work as the ThreadPool watis for one of two things to happen:
    1.An existing thread becomes free to process the work.
    2.No existing thread becomes free for 500ms, so a new thread is created.

    Basically, it means that when the number of Busy threads is greater than Min threads, you are likely paying 500ms delay before network traffic is processed by the application. Also, it is important to note that when an existing thread stays idle for longer than 15s(based on what i remember), it will be cleaned up and this cycle of growth and shrinkage can repeat.

    Recommendation
    Given this information, we strongly recommend that customers set the minimum configuration value for IOCP and WORKER threads to something larger than the default value. We can't give one-size-fits-all guidance. so each customer needs to fine-tune this setting to their specific needs. A good starting place is 200 or 300, then test and tweak as needed.

    Minimum threads setting configuration
    a. using the ThreadPool.SetMinThreads(...) method in application during starting. this is preferred mechanism.
    b. using the minIoThreads or minWorkerThreads configuration setting under the <processModel> configuration element in Machine.config, usually located at %SytemRoot%Microsoft.NETFramework[versionNumber]CONFIG.

  • 相关阅读:
    (15)疯狂的程序员----《绝影》
    (14)嵌入式软件开发工程师技能要求总结
    (13)碎片化阅读只会让你变得越来越愚蠢
    (12)QT中搭建opencv开发环境
    (11)git服务器的安装和配置
    (10)python学习笔记一
    (3.3)狄泰软件学院C++课程学习剖析四
    (9)Linux下gdb调试学习
    (8)Linux(客户端)和Windows(服务端)下socket通信实例
    springMVC伪静态
  • 原文地址:https://www.cnblogs.com/yycelsu/p/13376035.html
Copyright © 2011-2022 走看看