You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version 4.0 of the Java client brings support for Java non-blocking
971
-
IO (a.k.a Java NIO). NIO isn't supposed to be faster than blocking IO,
972
-
it simply allows to control resources (in this case, threads) more easily.
970
+
Version 5.27.0 of the Java client brings support for [Netty](https://netty.io/) for network I/O.
971
+
Netty isn't supposed to be faster than blocking I/O, it gives more control on resources (e.g. threads) and provides advanced networking options, like [TLS with OpenSSL](https://netty.io/wiki/forked-tomcat-native.html) and [native transports](https://netty.io/wiki/native-transports.html) (epoll, io_uring, kqueue).
973
972
974
-
With the default blocking IO mode, each connection uses a thread to read
975
-
from the network socket. With the NIO mode, you can control the number of
976
-
threads that read and write from/to the network socket.
973
+
With the default blocking I/O mode, each connection uses a thread to read from the network socket.
974
+
With Netty, you can control the number of threads that read and write from/to the network.
977
975
978
-
Use the NIO mode if your Java process uses many connections (dozens or hundreds).
979
-
You should use fewer threads than with the default blocking mode. With the
980
-
appropriate number of threads set, you shouldn't
981
-
experience any decrease in performance, especially if the connections are
982
-
not so busy.
976
+
Use Netty if your Java process uses many connections (dozens or hundreds).
977
+
You should use fewer threads than with the default blocking mode.
978
+
With the appropriate number of threads set, you shouldn't experience any decrease in performance, especially if the connections are not so busy.
983
979
984
-
NIO must be enabled explicitly:
980
+
Netty is activated and configured with the `ConnectionFactory#netty()` helper.
981
+
Netty's `EventLoopGroup` is the most important setting for an application picky about the number of threads.
982
+
Here is an example of how to set it with 4 threads:
// dispose the event loop group after closing all connections
993
+
eventLoopGroup.shutdownGracefully();
989
994
```
990
995
991
-
The NIO mode can be configured through the `NioParams` class:
996
+
Note the event loop group must be disposed of after the connection closes its connections.
997
+
If no event loop group is set, each connection will use its own, 1-thread event loop group (and will take care of closing it).
998
+
This is far from optimal, this is why setting an `EventLoopGroup` is highly recommended when using Netty.
999
+
1000
+
Netty uses its own `SslContext` API for [TLS](#tls) configuration (_not_ JDK's `SSLContext`), so the `ConnectionFactory#useSslProtocol()` methods have no effect when Netty is activated.
1001
+
Use `ConnectionFactory.netty().sslContext(SslContext)` instead, along with Netty's `SslContextBuilder` class.
0 commit comments