You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2020/12/26 03:06:31 UTC
[pulsar] branch master updated: Make Netty Acceptor ThreadPool size
configurable (#9061)
This is an automated email from the ASF dual-hosted git repository.
penghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 2c3e33b Make Netty Acceptor ThreadPool size configurable (#9061)
2c3e33b is described below
commit 2c3e33be7d6f1e8beea4f6bf1382d03b91c4cb87
Author: Shoothzj <sh...@gmail.com>
AuthorDate: Sat Dec 26 11:06:04 2020 +0800
Make Netty Acceptor ThreadPool size configurable (#9061)
### Motivation
When the consumer application which serves ten thousands of consumers start, the default netty acceptor config opens slow. Make the consumer bootstrap costs long time.
---
conf/broker.conf | 3 +++
.../main/java/org/apache/pulsar/broker/ServiceConfiguration.java | 7 +++++++
.../main/java/org/apache/pulsar/broker/service/BrokerService.java | 3 ++-
.../main/java/org/apache/pulsar/broker/web/PulsarWebResource.java | 3 +--
site2/docs/reference-configuration.md | 1 +
5 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/conf/broker.conf b/conf/broker.conf
index 06cffb7..42cad7b 100644
--- a/conf/broker.conf
+++ b/conf/broker.conf
@@ -58,6 +58,9 @@ advertisedAddress=
# Enable or disable the HAProxy protocol.
haProxyProtocolEnabled=false
+# Number of threads to config Netty Acceptor. Default is 1
+numAcceptorThreads=
+
# Number of threads to use for Netty IO. Default is set to 2 * Runtime.getRuntime().availableProcessors()
numIOThreads=
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
index d065c85..1482835 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
@@ -171,6 +171,13 @@ public class ServiceConfiguration implements PulsarConfiguration {
private boolean haProxyProtocolEnabled;
@FieldContext(
+ category = CATEGORY_SERVER,
+ doc = "Number of threads to use for Netty Acceptor."
+ + " Default is set to `1`"
+ )
+ private int numAcceptorThreads = 1;
+
+ @FieldContext(
category = CATEGORY_SERVER,
doc = "Number of threads to use for Netty IO."
+ " Default is set to `2 * Runtime.getRuntime().availableProcessors()`"
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
index 792c676..d89e264 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
@@ -287,7 +287,8 @@ public class BrokerService implements Closeable, ZooKeeperCacheListener<Policies
final int numThreads = pulsar.getConfiguration().getNumIOThreads();
log.info("Using {} threads for broker service IO", numThreads);
- this.acceptorGroup = EventLoopUtil.newEventLoopGroup(1, acceptorThreadFactory);
+ this.acceptorGroup = EventLoopUtil.newEventLoopGroup(
+ pulsar.getConfiguration().getNumAcceptorThreads(), acceptorThreadFactory);
this.workerGroup = EventLoopUtil.newEventLoopGroup(numThreads, workersThreadFactory);
this.statsUpdater = Executors
.newSingleThreadScheduledExecutor(new DefaultThreadFactory("pulsar-stats-updater"));
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
index 94f181c..7a06c12 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
@@ -504,8 +504,7 @@ public abstract class PulsarWebResource {
try {
return nsService.getWebServiceUrlAsync(nsBundle, options).thenApply(optionUrl -> optionUrl.isPresent());
} catch (Exception e) {
- log.error("[{}] Failed to check whether namespace bundle is owned {}/{}", clientAppId(),
- fqnn.toString(), bundleRange, e);
+ log.error("Failed to check whether namespace bundle is owned {}/{}", fqnn.toString(), bundleRange, e);
throw new RestException(e);
}
}
diff --git a/site2/docs/reference-configuration.md b/site2/docs/reference-configuration.md
index 573a78f..6bebcc6 100644
--- a/site2/docs/reference-configuration.md
+++ b/site2/docs/reference-configuration.md
@@ -444,6 +444,7 @@ The [`pulsar-client`](reference-cli-tools.md#pulsar-client) CLI tool can be used
|webServicePort| THe port used by the standalone broker for HTTP requests |8080|
|bindAddress| The hostname or IP address on which the standalone service binds |0.0.0.0|
|advertisedAddress| The hostname or IP address that the standalone service advertises to the outside world. If not set, the value of `InetAddress.getLocalHost().getHostName()` is used. ||
+| numAcceptorThreads | Number of threads to use for Netty Acceptor | 1 |
| numIOThreads | Number of threads to use for Netty IO | 2 * Runtime.getRuntime().availableProcessors() |
| numHttpServerThreads | Number of threads to use for HTTP requests processing | 2 * Runtime.getRuntime().availableProcessors()|
|isRunningStandalone|This flag controls features that are meant to be used when running in standalone mode.|N/A|