apache / dubbo-docs

Apache Dubbo documentation
https://dubbo.apache.org
76 stars 66 forks source link

The default size of the services' Thread Pool(Fixed) is 200 #43

Closed bert82503 closed 6 years ago

bert82503 commented 6 years ago

The default size of the services' Thread Pool(Fixed) is 100 in user manual, but the source code of FixedThreadPool is 200. There are inconsistent.

1. desc of user manual

dubbo-protocol.mddubbo-provider.md

| 属性 | 对应URL参数 | 类型 | 是否必填 | 缺省值 | 作用 | 描述 | 兼容性 |
| threads | threads | int | 可选 | 100 | 性能调优 | 服务线程池大小(固定大小) | 2.0.5以上版本 |

| Attribute     | Corresponding URL parameter | Type           | Required    | Default Value                            | Function                  | Description                              | Compatibility |
| threads       | threads                     | int            | False       | 100                                      | Performance optimize      | The size of the services' Thread Pool(Fixed) | Above 2.0.5   |

2. source code of FixedThreadPool

org.apache.dubbo.common.Constants

    public static final String DEFAULT_THREAD_NAME = "Dubbo";

    public static final int DEFAULT_CORE_THREADS = 0;

    public static final int DEFAULT_THREADS = 200;

org.apache.dubbo.common.threadpool.support.fixed.FixedThreadPool

public class FixedThreadPool implements ThreadPool {

    @Override
    public Executor getExecutor(URL url) {
        String name = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME);
        int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
        int queues = url.getParameter(Constants.QUEUES_KEY, Constants.DEFAULT_QUEUES);
        return new ThreadPoolExecutor(threads, threads, 0, TimeUnit.MILLISECONDS,
                queues == 0 ? new SynchronousQueue<Runnable>() :
                        (queues < 0 ? new LinkedBlockingQueue<Runnable>()
                                : new LinkedBlockingQueue<Runnable>(queues)),
                new NamedInternalThreadFactory(name, true), new AbortPolicyWithReport(name, url));
    }

}