Skip to content

Commit c98ceb8

Browse files
Make No. of Transport Threads == Available CPUs (#56488)
We never do any file IO or other blocking work on the transport threads so no tangible benefit can be derived from using more threads than CPUs for IO. There are however significant downsides to using more threads than necessary with Netty in particular. Since we use the default setting for `io.netty.allocator.useCacheForAllThreads` which is `true` we end up using up to `16MB` of thread local buffer cache for each transport thread. Meaning we potentially waste CPUs * 16MB of heap for unnecessary IO threads in addition to obvious inefficiencies of artificially adding extra context switches.
1 parent c4277ce commit c98ceb8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class Netty4Transport extends TcpTransport {
7878

7979
public static final Setting<Integer> WORKER_COUNT =
8080
new Setting<>("transport.netty.worker_count",
81-
(s) -> Integer.toString(EsExecutors.allocatedProcessors(s) * 2),
81+
(s) -> Integer.toString(EsExecutors.allocatedProcessors(s)),
8282
(s) -> Setting.parseInt(s, 1, "transport.netty.worker_count"), Property.NodeScope);
8383

8484
public static final Setting<ByteSizeValue> NETTY_RECEIVE_PREDICTOR_SIZE = Setting.byteSizeSetting(

plugins/transport-nio/src/main/java/org/elasticsearch/transport/nio/NioTransportPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class NioTransportPlugin extends Plugin implements NetworkPlugin {
5757

5858
public static final Setting<Integer> NIO_WORKER_COUNT =
5959
new Setting<>("transport.nio.worker_count",
60-
(s) -> Integer.toString(EsExecutors.allocatedProcessors(s) * 2),
60+
(s) -> Integer.toString(EsExecutors.allocatedProcessors(s)),
6161
(s) -> Setting.parseInt(s, 1, "transport.nio.worker_count"), Setting.Property.NodeScope);
6262
public static final Setting<Integer> NIO_HTTP_WORKER_COUNT =
6363
intSetting("http.nio.worker_count", 0, 0, Setting.Property.NodeScope);

0 commit comments

Comments
 (0)