You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2024/05/08 03:56:42 UTC
(pulsar) branch master updated: [improve][ws] Add memory limit configuration for Pulsar client used in Websocket proxy (#22666)
This is an automated email from the ASF dual-hosted git repository.
lhotari 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 80d46758e89 [improve][ws] Add memory limit configuration for Pulsar client used in Websocket proxy (#22666)
80d46758e89 is described below
commit 80d46758e89b088688d521aa8ae401bfb00c98b2
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Wed May 8 06:56:35 2024 +0300
[improve][ws] Add memory limit configuration for Pulsar client used in Websocket proxy (#22666)
---
conf/broker.conf | 3 +++
conf/standalone.conf | 3 +++
conf/websocket.conf | 3 +++
.../main/java/org/apache/pulsar/broker/ServiceConfiguration.java | 7 +++++++
.../main/java/org/apache/pulsar/websocket/WebSocketService.java | 3 ++-
.../pulsar/websocket/service/WebSocketProxyConfiguration.java | 3 +++
6 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/conf/broker.conf b/conf/broker.conf
index d97e3a5ef89..1b51ff47551 100644
--- a/conf/broker.conf
+++ b/conf/broker.conf
@@ -1544,6 +1544,9 @@ webSocketNumServiceThreads=
# Number of connections per Broker in Pulsar Client used in WebSocket proxy
webSocketConnectionsPerBroker=
+# Memory limit in MBs for direct memory in Pulsar Client used in WebSocket proxy
+webSocketPulsarClientMemoryLimitInMB=0
+
# Time in milliseconds that idle WebSocket session times out
webSocketSessionIdleTimeoutMillis=300000
diff --git a/conf/standalone.conf b/conf/standalone.conf
index b04e5ccefa6..51035235d4d 100644
--- a/conf/standalone.conf
+++ b/conf/standalone.conf
@@ -967,6 +967,9 @@ webSocketNumIoThreads=8
# Number of connections per Broker in Pulsar Client used in WebSocket proxy
webSocketConnectionsPerBroker=8
+# Memory limit in MBs for direct memory in Pulsar Client used in WebSocket proxy
+webSocketPulsarClientMemoryLimitInMB=0
+
# Time in milliseconds that idle WebSocket session times out
webSocketSessionIdleTimeoutMillis=300000
diff --git a/conf/websocket.conf b/conf/websocket.conf
index 9051f3b590c..91f7f7d4c23 100644
--- a/conf/websocket.conf
+++ b/conf/websocket.conf
@@ -71,6 +71,9 @@ numHttpServerThreads=
# Number of connections per Broker in Pulsar Client used in WebSocket proxy
webSocketConnectionsPerBroker=
+# Memory limit in MBs for direct memory in Pulsar Client used in WebSocket proxy
+webSocketPulsarClientMemoryLimitInMB=0
+
# Time in milliseconds that idle WebSocket session times out
webSocketSessionIdleTimeoutMillis=300000
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 156c83bd696..a9d170ea5de 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
@@ -2912,6 +2912,13 @@ public class ServiceConfiguration implements PulsarConfiguration {
doc = "Number of connections per Broker in Pulsar Client used in WebSocket proxy"
)
private int webSocketConnectionsPerBroker = Runtime.getRuntime().availableProcessors();
+
+ @FieldContext(
+ category = CATEGORY_WEBSOCKET,
+ doc = "Memory limit in MBs for direct memory in Pulsar Client used in WebSocket proxy"
+ )
+ private int webSocketPulsarClientMemoryLimitInMB = 0;
+
@FieldContext(
category = CATEGORY_WEBSOCKET,
doc = "Time in milliseconds that idle WebSocket session times out"
diff --git a/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/WebSocketService.java b/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/WebSocketService.java
index 66b2a0075ec..889f4431cc3 100644
--- a/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/WebSocketService.java
+++ b/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/WebSocketService.java
@@ -195,7 +195,8 @@ public class WebSocketService implements Closeable {
private PulsarClient createClientInstance(ClusterData clusterData) throws IOException {
ClientBuilder clientBuilder = PulsarClient.builder() //
- .memoryLimit(0, SizeUnit.BYTES)
+ .memoryLimit(SizeUnit.MEGA_BYTES.toBytes(config.getWebSocketPulsarClientMemoryLimitInMB()),
+ SizeUnit.BYTES)
.statsInterval(0, TimeUnit.SECONDS) //
.enableTls(config.isTlsEnabled()) //
.allowTlsInsecureConnection(config.isTlsAllowInsecureConnection()) //
diff --git a/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java b/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java
index 3fcbcf4b215..31a1adc2915 100644
--- a/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java
+++ b/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java
@@ -176,6 +176,9 @@ public class WebSocketProxyConfiguration implements PulsarConfiguration {
@FieldContext(doc = "Number of connections per broker in Pulsar client used in WebSocket proxy")
private int webSocketConnectionsPerBroker = Runtime.getRuntime().availableProcessors();
+ @FieldContext(doc = "Memory limit in MBs for direct memory in Pulsar Client used in WebSocket proxy")
+ private int webSocketPulsarClientMemoryLimitInMB = 0;
+
@FieldContext(doc = "Timeout of idling WebSocket session (in milliseconds)")
private int webSocketSessionIdleTimeoutMillis = 300000;