This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git
The following commit(s) were added to refs/heads/main by this push:
new 8f51b2d6f892 Update Java client docs about Pulsar BOM, Spring Boot and
add Netty opts
8f51b2d6f892 is described below
commit 8f51b2d6f8929f708509bc254530b56a2c828faf
Author: Lari Hotari <[email protected]>
AuthorDate: Thu Oct 24 09:15:15 2024 +0300
Update Java client docs about Pulsar BOM, Spring Boot and add Netty opts
---
docs/client-libraries-java-setup.md | 61 +++++++++++++++++++---
.../version-3.2.x/client-libraries-java-setup.md | 61 +++++++++++++++++++---
.../version-3.3.x/client-libraries-java-setup.md | 61 +++++++++++++++++++---
.../version-4.0.x/client-libraries-java-setup.md | 61 +++++++++++++++++++---
4 files changed, 220 insertions(+), 24 deletions(-)
diff --git a/docs/client-libraries-java-setup.md
b/docs/client-libraries-java-setup.md
index 35200cd41fa4..09b4b8914697 100644
--- a/docs/client-libraries-java-setup.md
+++ b/docs/client-libraries-java-setup.md
@@ -51,7 +51,13 @@ dependencies {
While the above dependencies are sufficient to obtain the Pulsar Java client,
it is recommended to also use the [Pulsar
BOM](https://github.com/apache/pulsar/blob/master/pip/pip-326.md) to ensure
that all Pulsar dependencies (both direct and transitive) are at the same
expected version.
In order to use the BOM, the previous directions are modified slightly as
follows:
-#### Maven
+#### Maven {#pulsar-bom-maven}
+
+:::note
+
+Please notice that when using Spring Boot and the default Maven build, it is
necessary to use Spring Boot Maven plugin features to configure the Pulsar
version. Please refer to the [Spring Boot using Maven](#spring-boot-maven)
section for more details.
+
+:::
If you use Maven, add the following information to the `pom.xml` file.
@@ -75,13 +81,13 @@ If you use Maven, add the following information to the
`pom.xml` file.
</dependency>
```
-#### Gradle
+#### Gradle {#pulsar-bom-gradle}
If you use Gradle, add the following information to the `build.gradle` file.
:::note
-Please notice that when using Spring Boot and the default Gradle build with
the Spring Dependency Management plugin (`io.spring.dependency-management`), it
is necessary to use Spring Dependency Management plugin features to configure
the Pulsar version. Please refer to the next section for more details.
+Please notice that when using Spring Boot and the default Gradle build with
the Spring Dependency Management plugin (`io.spring.dependency-management`), it
is necessary to use Spring Dependency Management plugin features to configure
the Pulsar version. Please refer to the [Spring Boot using
Gradle](#spring-boot-gradle) section for more details.
:::
@@ -96,7 +102,27 @@ dependencies {
Note that the version is number for the `pulsar-client` dependency is now
omitted as the Pulsar BOM dictates which version is used.
-#### Gradle with Spring Boot, using Spring Dependency Management plugin
+### Spring Boot
+
+You can find more information about using Pulsar with Spring Boot in the
[Spring Boot
documentation](https://docs.spring.io/spring-boot/reference/messaging/pulsar.html).
+
+#### Spring Boot using Maven {#spring-boot-maven}
+
+The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html)
define `pulsar.version` and `pulsar-reactive.version` for controlling the
Pulsar Java client version and Pulsar Reactive client version.
+
+```xml
+<!-- in your <properties> block -->
+<pulsar.version>@pulsar:version@</pulsar.version>
+
+<!-- in your <dependencies> block -->
+<!-- The Pulsar Java client will be automatically added to dependencies as a
transitive dependency of the spring-boot-starter-pulsar dependency -->
+<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-pulsar</artifactId>
+</dependency>
+```
+
+#### Spring Boot using Gradle {#spring-boot-gradle}
Please notice that when using the Spring Dependency Management plugin
(`io.spring.dependency-management`) in Gradle, it is necessary to use Spring
Dependency Management plugin features to configure the Pulsar version.
The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html)
define `pulsar.version` and `pulsar-reactive.version` for controlling the
Pulsar Java client version and Pulsar Reactive client version.
@@ -104,6 +130,7 @@ The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-bo
To use a specific Pulsar version for the Pulsar Java client in a Spring Boot
application using Gradle, add the following to your `build.gradle` file in a
Spring Boot project:
```groovy
+// Alternatively, you can set the `pulsar.version` property in the
`gradle.properties` file.
ext['pulsar.version'] = '@pulsar:version@'
// The Pulsar Java client will be automatically added to dependencies as a
transitive dependency of the spring-boot-starter-pulsar dependency
@@ -112,8 +139,6 @@ dependencies {
}
```
-You can find more information about Spring Pulsar in the [Spring for Apache
Pulsar documentation](https://spring.io/projects/spring-pulsar).
-
## Step 2: Connect to Pulsar cluster
To connect to Pulsar using client libraries, you need to specify a [Pulsar
protocol](developing-binary-protocol.md) URL.
@@ -135,3 +160,27 @@ If you use [mTLS](security-tls-authentication.md)
authentication, add `+ssl` in
```http
pulsar+ssl://pulsar.us-west.example.com:6651
```
+
+## Java client Performance considerations {#java-client-performance}
+
+### Increasing the memory limit
+
+For high-throughput applications, you can increase the amount of memory with
the Java client builder's [`memoryLimit` configuration
option](https://pulsar.apache.org/api/client/4.0.x/org/apache/pulsar/client/api/ClientBuilder.html#memoryLimit(long,org.apache.pulsar.client.api.SizeUnit)).
The default limit is 64MB which is usually too low for high-throughput
applications.
+
+By default Java applications have a limit for direct memory allocations. The
allocations are limited by the `-XX:MaxDirectMemorySize` JVM option. In many
JVM implementations, this defaults to the maximum heap size unless explicitly
set. Allocations happen outside of the Java heap.
+
+### Enabling optimized Netty direct memory buffer access
+
+The Pulsar Java client uses [Netty](https://netty.io/) under the hood and uses
Netty direct buffers for data transport.
+
+Netty has a feature that allows optimized direct memory buffer access. This
feature enables Netty to use low level APIs such as `sun.misc.Unsafe` for
direct memory operations, which provides faster allocation and deallocation of
direct buffers.
+
+To enable this feature in Java clients since Java 11, you need to add the
following JVM options to the application that uses the Java client:
+
+- `--add-opens java.base/java.nio=ALL-UNNAMED`
+- `--add-opens java.base/jdk.internal.misc=ALL-UNNAMED`
+
+In addition, you need to add one of the following JVM options:
+
+- `-Dorg.apache.pulsar.shade.io.netty.tryReflectionSetAccessible=true` for the
default shaded Pulsar client
+- `-Dio.netty.tryReflectionSetAccessible=true` for the unshaded "original"
Pulsar client
\ No newline at end of file
diff --git a/versioned_docs/version-3.2.x/client-libraries-java-setup.md
b/versioned_docs/version-3.2.x/client-libraries-java-setup.md
index 35200cd41fa4..09b4b8914697 100644
--- a/versioned_docs/version-3.2.x/client-libraries-java-setup.md
+++ b/versioned_docs/version-3.2.x/client-libraries-java-setup.md
@@ -51,7 +51,13 @@ dependencies {
While the above dependencies are sufficient to obtain the Pulsar Java client,
it is recommended to also use the [Pulsar
BOM](https://github.com/apache/pulsar/blob/master/pip/pip-326.md) to ensure
that all Pulsar dependencies (both direct and transitive) are at the same
expected version.
In order to use the BOM, the previous directions are modified slightly as
follows:
-#### Maven
+#### Maven {#pulsar-bom-maven}
+
+:::note
+
+Please notice that when using Spring Boot and the default Maven build, it is
necessary to use Spring Boot Maven plugin features to configure the Pulsar
version. Please refer to the [Spring Boot using Maven](#spring-boot-maven)
section for more details.
+
+:::
If you use Maven, add the following information to the `pom.xml` file.
@@ -75,13 +81,13 @@ If you use Maven, add the following information to the
`pom.xml` file.
</dependency>
```
-#### Gradle
+#### Gradle {#pulsar-bom-gradle}
If you use Gradle, add the following information to the `build.gradle` file.
:::note
-Please notice that when using Spring Boot and the default Gradle build with
the Spring Dependency Management plugin (`io.spring.dependency-management`), it
is necessary to use Spring Dependency Management plugin features to configure
the Pulsar version. Please refer to the next section for more details.
+Please notice that when using Spring Boot and the default Gradle build with
the Spring Dependency Management plugin (`io.spring.dependency-management`), it
is necessary to use Spring Dependency Management plugin features to configure
the Pulsar version. Please refer to the [Spring Boot using
Gradle](#spring-boot-gradle) section for more details.
:::
@@ -96,7 +102,27 @@ dependencies {
Note that the version is number for the `pulsar-client` dependency is now
omitted as the Pulsar BOM dictates which version is used.
-#### Gradle with Spring Boot, using Spring Dependency Management plugin
+### Spring Boot
+
+You can find more information about using Pulsar with Spring Boot in the
[Spring Boot
documentation](https://docs.spring.io/spring-boot/reference/messaging/pulsar.html).
+
+#### Spring Boot using Maven {#spring-boot-maven}
+
+The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html)
define `pulsar.version` and `pulsar-reactive.version` for controlling the
Pulsar Java client version and Pulsar Reactive client version.
+
+```xml
+<!-- in your <properties> block -->
+<pulsar.version>@pulsar:version@</pulsar.version>
+
+<!-- in your <dependencies> block -->
+<!-- The Pulsar Java client will be automatically added to dependencies as a
transitive dependency of the spring-boot-starter-pulsar dependency -->
+<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-pulsar</artifactId>
+</dependency>
+```
+
+#### Spring Boot using Gradle {#spring-boot-gradle}
Please notice that when using the Spring Dependency Management plugin
(`io.spring.dependency-management`) in Gradle, it is necessary to use Spring
Dependency Management plugin features to configure the Pulsar version.
The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html)
define `pulsar.version` and `pulsar-reactive.version` for controlling the
Pulsar Java client version and Pulsar Reactive client version.
@@ -104,6 +130,7 @@ The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-bo
To use a specific Pulsar version for the Pulsar Java client in a Spring Boot
application using Gradle, add the following to your `build.gradle` file in a
Spring Boot project:
```groovy
+// Alternatively, you can set the `pulsar.version` property in the
`gradle.properties` file.
ext['pulsar.version'] = '@pulsar:version@'
// The Pulsar Java client will be automatically added to dependencies as a
transitive dependency of the spring-boot-starter-pulsar dependency
@@ -112,8 +139,6 @@ dependencies {
}
```
-You can find more information about Spring Pulsar in the [Spring for Apache
Pulsar documentation](https://spring.io/projects/spring-pulsar).
-
## Step 2: Connect to Pulsar cluster
To connect to Pulsar using client libraries, you need to specify a [Pulsar
protocol](developing-binary-protocol.md) URL.
@@ -135,3 +160,27 @@ If you use [mTLS](security-tls-authentication.md)
authentication, add `+ssl` in
```http
pulsar+ssl://pulsar.us-west.example.com:6651
```
+
+## Java client Performance considerations {#java-client-performance}
+
+### Increasing the memory limit
+
+For high-throughput applications, you can increase the amount of memory with
the Java client builder's [`memoryLimit` configuration
option](https://pulsar.apache.org/api/client/4.0.x/org/apache/pulsar/client/api/ClientBuilder.html#memoryLimit(long,org.apache.pulsar.client.api.SizeUnit)).
The default limit is 64MB which is usually too low for high-throughput
applications.
+
+By default Java applications have a limit for direct memory allocations. The
allocations are limited by the `-XX:MaxDirectMemorySize` JVM option. In many
JVM implementations, this defaults to the maximum heap size unless explicitly
set. Allocations happen outside of the Java heap.
+
+### Enabling optimized Netty direct memory buffer access
+
+The Pulsar Java client uses [Netty](https://netty.io/) under the hood and uses
Netty direct buffers for data transport.
+
+Netty has a feature that allows optimized direct memory buffer access. This
feature enables Netty to use low level APIs such as `sun.misc.Unsafe` for
direct memory operations, which provides faster allocation and deallocation of
direct buffers.
+
+To enable this feature in Java clients since Java 11, you need to add the
following JVM options to the application that uses the Java client:
+
+- `--add-opens java.base/java.nio=ALL-UNNAMED`
+- `--add-opens java.base/jdk.internal.misc=ALL-UNNAMED`
+
+In addition, you need to add one of the following JVM options:
+
+- `-Dorg.apache.pulsar.shade.io.netty.tryReflectionSetAccessible=true` for the
default shaded Pulsar client
+- `-Dio.netty.tryReflectionSetAccessible=true` for the unshaded "original"
Pulsar client
\ No newline at end of file
diff --git a/versioned_docs/version-3.3.x/client-libraries-java-setup.md
b/versioned_docs/version-3.3.x/client-libraries-java-setup.md
index 35200cd41fa4..09b4b8914697 100644
--- a/versioned_docs/version-3.3.x/client-libraries-java-setup.md
+++ b/versioned_docs/version-3.3.x/client-libraries-java-setup.md
@@ -51,7 +51,13 @@ dependencies {
While the above dependencies are sufficient to obtain the Pulsar Java client,
it is recommended to also use the [Pulsar
BOM](https://github.com/apache/pulsar/blob/master/pip/pip-326.md) to ensure
that all Pulsar dependencies (both direct and transitive) are at the same
expected version.
In order to use the BOM, the previous directions are modified slightly as
follows:
-#### Maven
+#### Maven {#pulsar-bom-maven}
+
+:::note
+
+Please notice that when using Spring Boot and the default Maven build, it is
necessary to use Spring Boot Maven plugin features to configure the Pulsar
version. Please refer to the [Spring Boot using Maven](#spring-boot-maven)
section for more details.
+
+:::
If you use Maven, add the following information to the `pom.xml` file.
@@ -75,13 +81,13 @@ If you use Maven, add the following information to the
`pom.xml` file.
</dependency>
```
-#### Gradle
+#### Gradle {#pulsar-bom-gradle}
If you use Gradle, add the following information to the `build.gradle` file.
:::note
-Please notice that when using Spring Boot and the default Gradle build with
the Spring Dependency Management plugin (`io.spring.dependency-management`), it
is necessary to use Spring Dependency Management plugin features to configure
the Pulsar version. Please refer to the next section for more details.
+Please notice that when using Spring Boot and the default Gradle build with
the Spring Dependency Management plugin (`io.spring.dependency-management`), it
is necessary to use Spring Dependency Management plugin features to configure
the Pulsar version. Please refer to the [Spring Boot using
Gradle](#spring-boot-gradle) section for more details.
:::
@@ -96,7 +102,27 @@ dependencies {
Note that the version is number for the `pulsar-client` dependency is now
omitted as the Pulsar BOM dictates which version is used.
-#### Gradle with Spring Boot, using Spring Dependency Management plugin
+### Spring Boot
+
+You can find more information about using Pulsar with Spring Boot in the
[Spring Boot
documentation](https://docs.spring.io/spring-boot/reference/messaging/pulsar.html).
+
+#### Spring Boot using Maven {#spring-boot-maven}
+
+The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html)
define `pulsar.version` and `pulsar-reactive.version` for controlling the
Pulsar Java client version and Pulsar Reactive client version.
+
+```xml
+<!-- in your <properties> block -->
+<pulsar.version>@pulsar:version@</pulsar.version>
+
+<!-- in your <dependencies> block -->
+<!-- The Pulsar Java client will be automatically added to dependencies as a
transitive dependency of the spring-boot-starter-pulsar dependency -->
+<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-pulsar</artifactId>
+</dependency>
+```
+
+#### Spring Boot using Gradle {#spring-boot-gradle}
Please notice that when using the Spring Dependency Management plugin
(`io.spring.dependency-management`) in Gradle, it is necessary to use Spring
Dependency Management plugin features to configure the Pulsar version.
The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html)
define `pulsar.version` and `pulsar-reactive.version` for controlling the
Pulsar Java client version and Pulsar Reactive client version.
@@ -104,6 +130,7 @@ The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-bo
To use a specific Pulsar version for the Pulsar Java client in a Spring Boot
application using Gradle, add the following to your `build.gradle` file in a
Spring Boot project:
```groovy
+// Alternatively, you can set the `pulsar.version` property in the
`gradle.properties` file.
ext['pulsar.version'] = '@pulsar:version@'
// The Pulsar Java client will be automatically added to dependencies as a
transitive dependency of the spring-boot-starter-pulsar dependency
@@ -112,8 +139,6 @@ dependencies {
}
```
-You can find more information about Spring Pulsar in the [Spring for Apache
Pulsar documentation](https://spring.io/projects/spring-pulsar).
-
## Step 2: Connect to Pulsar cluster
To connect to Pulsar using client libraries, you need to specify a [Pulsar
protocol](developing-binary-protocol.md) URL.
@@ -135,3 +160,27 @@ If you use [mTLS](security-tls-authentication.md)
authentication, add `+ssl` in
```http
pulsar+ssl://pulsar.us-west.example.com:6651
```
+
+## Java client Performance considerations {#java-client-performance}
+
+### Increasing the memory limit
+
+For high-throughput applications, you can increase the amount of memory with
the Java client builder's [`memoryLimit` configuration
option](https://pulsar.apache.org/api/client/4.0.x/org/apache/pulsar/client/api/ClientBuilder.html#memoryLimit(long,org.apache.pulsar.client.api.SizeUnit)).
The default limit is 64MB which is usually too low for high-throughput
applications.
+
+By default Java applications have a limit for direct memory allocations. The
allocations are limited by the `-XX:MaxDirectMemorySize` JVM option. In many
JVM implementations, this defaults to the maximum heap size unless explicitly
set. Allocations happen outside of the Java heap.
+
+### Enabling optimized Netty direct memory buffer access
+
+The Pulsar Java client uses [Netty](https://netty.io/) under the hood and uses
Netty direct buffers for data transport.
+
+Netty has a feature that allows optimized direct memory buffer access. This
feature enables Netty to use low level APIs such as `sun.misc.Unsafe` for
direct memory operations, which provides faster allocation and deallocation of
direct buffers.
+
+To enable this feature in Java clients since Java 11, you need to add the
following JVM options to the application that uses the Java client:
+
+- `--add-opens java.base/java.nio=ALL-UNNAMED`
+- `--add-opens java.base/jdk.internal.misc=ALL-UNNAMED`
+
+In addition, you need to add one of the following JVM options:
+
+- `-Dorg.apache.pulsar.shade.io.netty.tryReflectionSetAccessible=true` for the
default shaded Pulsar client
+- `-Dio.netty.tryReflectionSetAccessible=true` for the unshaded "original"
Pulsar client
\ No newline at end of file
diff --git a/versioned_docs/version-4.0.x/client-libraries-java-setup.md
b/versioned_docs/version-4.0.x/client-libraries-java-setup.md
index 35200cd41fa4..09b4b8914697 100644
--- a/versioned_docs/version-4.0.x/client-libraries-java-setup.md
+++ b/versioned_docs/version-4.0.x/client-libraries-java-setup.md
@@ -51,7 +51,13 @@ dependencies {
While the above dependencies are sufficient to obtain the Pulsar Java client,
it is recommended to also use the [Pulsar
BOM](https://github.com/apache/pulsar/blob/master/pip/pip-326.md) to ensure
that all Pulsar dependencies (both direct and transitive) are at the same
expected version.
In order to use the BOM, the previous directions are modified slightly as
follows:
-#### Maven
+#### Maven {#pulsar-bom-maven}
+
+:::note
+
+Please notice that when using Spring Boot and the default Maven build, it is
necessary to use Spring Boot Maven plugin features to configure the Pulsar
version. Please refer to the [Spring Boot using Maven](#spring-boot-maven)
section for more details.
+
+:::
If you use Maven, add the following information to the `pom.xml` file.
@@ -75,13 +81,13 @@ If you use Maven, add the following information to the
`pom.xml` file.
</dependency>
```
-#### Gradle
+#### Gradle {#pulsar-bom-gradle}
If you use Gradle, add the following information to the `build.gradle` file.
:::note
-Please notice that when using Spring Boot and the default Gradle build with
the Spring Dependency Management plugin (`io.spring.dependency-management`), it
is necessary to use Spring Dependency Management plugin features to configure
the Pulsar version. Please refer to the next section for more details.
+Please notice that when using Spring Boot and the default Gradle build with
the Spring Dependency Management plugin (`io.spring.dependency-management`), it
is necessary to use Spring Dependency Management plugin features to configure
the Pulsar version. Please refer to the [Spring Boot using
Gradle](#spring-boot-gradle) section for more details.
:::
@@ -96,7 +102,27 @@ dependencies {
Note that the version is number for the `pulsar-client` dependency is now
omitted as the Pulsar BOM dictates which version is used.
-#### Gradle with Spring Boot, using Spring Dependency Management plugin
+### Spring Boot
+
+You can find more information about using Pulsar with Spring Boot in the
[Spring Boot
documentation](https://docs.spring.io/spring-boot/reference/messaging/pulsar.html).
+
+#### Spring Boot using Maven {#spring-boot-maven}
+
+The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html)
define `pulsar.version` and `pulsar-reactive.version` for controlling the
Pulsar Java client version and Pulsar Reactive client version.
+
+```xml
+<!-- in your <properties> block -->
+<pulsar.version>@pulsar:version@</pulsar.version>
+
+<!-- in your <dependencies> block -->
+<!-- The Pulsar Java client will be automatically added to dependencies as a
transitive dependency of the spring-boot-starter-pulsar dependency -->
+<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-pulsar</artifactId>
+</dependency>
+```
+
+#### Spring Boot using Gradle {#spring-boot-gradle}
Please notice that when using the Spring Dependency Management plugin
(`io.spring.dependency-management`) in Gradle, it is necessary to use Spring
Dependency Management plugin features to configure the Pulsar version.
The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html)
define `pulsar.version` and `pulsar-reactive.version` for controlling the
Pulsar Java client version and Pulsar Reactive client version.
@@ -104,6 +130,7 @@ The Spring Boot [Dependency Version
properties](https://docs.spring.io/spring-bo
To use a specific Pulsar version for the Pulsar Java client in a Spring Boot
application using Gradle, add the following to your `build.gradle` file in a
Spring Boot project:
```groovy
+// Alternatively, you can set the `pulsar.version` property in the
`gradle.properties` file.
ext['pulsar.version'] = '@pulsar:version@'
// The Pulsar Java client will be automatically added to dependencies as a
transitive dependency of the spring-boot-starter-pulsar dependency
@@ -112,8 +139,6 @@ dependencies {
}
```
-You can find more information about Spring Pulsar in the [Spring for Apache
Pulsar documentation](https://spring.io/projects/spring-pulsar).
-
## Step 2: Connect to Pulsar cluster
To connect to Pulsar using client libraries, you need to specify a [Pulsar
protocol](developing-binary-protocol.md) URL.
@@ -135,3 +160,27 @@ If you use [mTLS](security-tls-authentication.md)
authentication, add `+ssl` in
```http
pulsar+ssl://pulsar.us-west.example.com:6651
```
+
+## Java client Performance considerations {#java-client-performance}
+
+### Increasing the memory limit
+
+For high-throughput applications, you can increase the amount of memory with
the Java client builder's [`memoryLimit` configuration
option](https://pulsar.apache.org/api/client/4.0.x/org/apache/pulsar/client/api/ClientBuilder.html#memoryLimit(long,org.apache.pulsar.client.api.SizeUnit)).
The default limit is 64MB which is usually too low for high-throughput
applications.
+
+By default Java applications have a limit for direct memory allocations. The
allocations are limited by the `-XX:MaxDirectMemorySize` JVM option. In many
JVM implementations, this defaults to the maximum heap size unless explicitly
set. Allocations happen outside of the Java heap.
+
+### Enabling optimized Netty direct memory buffer access
+
+The Pulsar Java client uses [Netty](https://netty.io/) under the hood and uses
Netty direct buffers for data transport.
+
+Netty has a feature that allows optimized direct memory buffer access. This
feature enables Netty to use low level APIs such as `sun.misc.Unsafe` for
direct memory operations, which provides faster allocation and deallocation of
direct buffers.
+
+To enable this feature in Java clients since Java 11, you need to add the
following JVM options to the application that uses the Java client:
+
+- `--add-opens java.base/java.nio=ALL-UNNAMED`
+- `--add-opens java.base/jdk.internal.misc=ALL-UNNAMED`
+
+In addition, you need to add one of the following JVM options:
+
+- `-Dorg.apache.pulsar.shade.io.netty.tryReflectionSetAccessible=true` for the
default shaded Pulsar client
+- `-Dio.netty.tryReflectionSetAccessible=true` for the unshaded "original"
Pulsar client
\ No newline at end of file