Skip to content

Commit

Permalink
[Enhancement] Support to configure the number of http worker threads …
Browse files Browse the repository at this point in the history
…on FE (StarRocks#37530)

Why I'm doing:
Http worker threads on FE are used to deal with http requests.  Some requests may do heavy operations which will block threads, such as transaction stream load commit, and other operations that need to get lock. As a result, http server can't deal with other requests.  Before optimizing these heavy operations, we first make the number of http worker threads to be configurable, and increase it as a candidate solution if the problem happens.

What I'm doing:
Add a configuration to adjust the number of http worker threads on FE

Signed-off-by: PengFei Li <[email protected]>
Signed-off-by: 张敢 <[email protected]>
  • Loading branch information
banmoy authored and Zhangg7723 committed Dec 26, 2023
1 parent 603b927 commit 754e815
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/en/administration/FE_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,12 @@ This section provides an overview of the static parameters that you can configur
- **Default:** 8030
- **Description:** The port on which the HTTP server in the FE node listens.

#### http_worker_threads_num

- **Default:** 0
- **Description:** Number of worker threads for http server to deal with http requests. For a negative or 0 value, the number of threads will be twice the number of cpu cores.
- Introduced in: 2.5.18,3.0.10,3.1.7,3.2.2

#### http_backlog_num

- **Default:** 1024
Expand Down
6 changes: 6 additions & 0 deletions docs/zh/administration/FE_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,12 @@ Compaction Score 代表了一个表分区是否值得进行 Compaction 的评分
- 含义:FE 节点上 HTTP 服务器的端口。
- 默认值:8030

#### http_worker_threads_num

- 含义:Http Server 用于处理 HTTP 请求的线程数。如果配置为负数或 0 ,线程数将设置为 CPU 核数的 2 倍。
- 默认值:0
- 引入版本:2.5.18,3.0.10,3.1.7,3.2.2

#### http_backlog_num

- 含义:HTTP 服务器支持的 Backlog 队列长度。
Expand Down
11 changes: 11 additions & 0 deletions fe/fe-core/src/main/java/com/starrocks/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,17 @@ public class Config extends ConfigBase {
@ConfField
public static int http_port = 8030;

/**
* Number of worker threads for http server to deal with http requests which may do
* some I/O operations. If set with a non-positive value, it will use netty's default
* value <code>DEFAULT_EVENT_LOOP_THREADS</code> which is availableProcessors * 2. The
* default value is 0 which is same as the previous behaviour.
* See <a href="https://github.com/netty/netty/blob/netty-4.1.16.Final/transport/src/main/java/io/netty/channel/MultithreadEventLoopGroup.java#L40">DEFAULT_EVENT_LOOP_THREADS</a>
* for details.
*/
@ConfField
public static int http_worker_threads_num = 0;

/**
* The backlog_num for netty http server
* When you enlarge this backlog_num, you should ensure its value larger than
Expand Down
3 changes: 2 additions & 1 deletion fe/fe-core/src/main/java/com/starrocks/http/HttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ private class HttpServerThread implements Runnable {
public void run() {
// Configure the server.
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
int numWorkerThreads = Math.max(0, Config.http_worker_threads_num);
EventLoopGroup workerGroup = new NioEventLoopGroup(numWorkerThreads);
try {
serverBootstrap = new ServerBootstrap();
serverBootstrap.option(ChannelOption.SO_BACKLOG, Config.http_backlog_num);
Expand Down

0 comments on commit 754e815

Please sign in to comment.