This is an automated email from the ASF dual-hosted git repository. lhotari pushed a commit to branch branch-2.8 in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 1742df8fa7d5f98976af02cd643c56c2a928bffd Author: Addison Higham <addis...@gmail.com> AuthorDate: Sun Jan 30 13:04:26 2022 -0700 Allow config of IO and acceptor threads in proxy (#14054) * Allow config of IO and acceptor threads in proxy Previously, the Pulasr Proxy did not allow configuration of the number of IO threads and acceptor threads in the proxy. These options can be very important to tune, as is tuneable in the broker, so this change simply matches the brokers perspective. Also, we increase the default number of IO threads to 2x number of processors instead of 1x, as in a single CPU config, it still makes sense to have 2 threads, at least for now, where some blocking operatings can happen (such as authn/authz plugins) * fix checkstyle (cherry picked from commit f455418c8e1efcd3895d4dab593aadb36a682165) --- .../org/apache/pulsar/proxy/server/ProxyConfiguration.java | 14 ++++++++++++++ .../java/org/apache/pulsar/proxy/server/ProxyService.java | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConfiguration.java b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConfiguration.java index 69b4480..a50ac70 100644 --- a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConfiguration.java +++ b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConfiguration.java @@ -495,6 +495,20 @@ public class ProxyConfiguration implements PulsarConfiguration { ) private int httpNumThreads = Math.max(8, 2 * Runtime.getRuntime().availableProcessors()); + @FieldContext( + category = CATEGORY_SERVER, + doc = "Number of threads to use for Netty IO." + + " Default is set to `2 * Runtime.getRuntime().availableProcessors()`" + ) + private int numIOThreads = 2 * Runtime.getRuntime().availableProcessors(); + + @FieldContext( + category = CATEGORY_SERVER, + doc = "Number of threads to use for Netty Acceptor." + + " Default is set to `1`" + ) + private int numAcceptorThreads = 1; + @Deprecated @FieldContext( category = CATEGORY_PLUGIN, diff --git a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java index c5e04b6..75f922d 100644 --- a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java +++ b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java @@ -101,8 +101,6 @@ public class ProxyService implements Closeable { private final ScheduledExecutorService statsExecutor; - private static final int numThreads = Runtime.getRuntime().availableProcessors(); - static final Gauge activeConnections = Gauge .build("pulsar_proxy_active_connections", "Number of connections currently active in the proxy").create() .register(); @@ -143,8 +141,10 @@ public class ProxyService implements Closeable { } else { proxyLogLevel = 0; } - this.acceptorGroup = EventLoopUtil.newEventLoopGroup(1, false, acceptorThreadFactory); - this.workerGroup = EventLoopUtil.newEventLoopGroup(numThreads, false, workersThreadFactory); + this.acceptorGroup = EventLoopUtil.newEventLoopGroup(proxyConfig.getNumAcceptorThreads(), + false, acceptorThreadFactory); + this.workerGroup = EventLoopUtil.newEventLoopGroup(proxyConfig.getNumIOThreads(), + false, workersThreadFactory); this.authenticationService = authenticationService; statsExecutor = Executors