Skip to content

Native Transports

Mark Paluch edited this page Dec 1, 2020 · 5 revisions

Netty provides three platform-specific JNI transports:

  • epoll on Linux

  • io_uring on Linux (Incubator)

  • kqueue on MacOS/BSD

Lettuce defaults to native transports if the appropriate library is available within its runtime. Using a native transport adds features specific to a particular platform, generate less garbage and generally improve performance when compared to the NIO based transport. Native transports are required to connect to Redis via Unix Domain Sockets and are suitable for TCP connections as well.

Native transports are available with:

  • Linux epoll x86_64 systems with a minimum netty version of 4.0.26.Final, requiring netty-transport-native-epoll, classifier linux-x86_64

    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-transport-native-epoll</artifactId>
        <version>${netty-version}</version>
        <classifier>linux-x86_64</classifier>
    </dependency>
  • Linux io_uring x86_64 systems with a minimum netty version of 4.1.54.Final, requiring netty-incubator-transport-native-io_uring, classifier linux-x86_64. Note that this transport is still experimental.

    <dependency>
        <groupId>io.netty.incubator</groupId>
        <artifactId>netty-incubator-transport-native-io_uring</artifactId>
        <version>0.0.1.Final</version>
        <classifier>linux-x86_64</classifier>
    </dependency>
  • MacOS kqueue x86_64 systems with a minimum netty version of 4.1.11.Final, requiring netty-transport-native-kqueue, classifier osx-x86_64

    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-transport-native-kqueue</artifactId>
        <version>${netty-version}</version>
        <classifier>osx-x86_64</classifier>
    </dependency>

You can disable native transport use through system properties. Set io.lettuce.core.epoll, io.lettuce.core.iouring respective io.lettuce.core.kqueue to false (default is true, if unset).

Limitations

Native transport support does not work with the shaded version of Lettuce because of two reasons:

  1. netty-transport-native-epoll and netty-transport-native-kqueue are not packaged into the shaded jar. So adding the jar to the classpath will resolve in different netty base classes (such as io.netty.channel.EventLoopGroup instead of com.lambdaworks.io.netty.channel.EventLoopGroup)

  2. Support for using epoll/kqueue with shaded netty requires netty 4.1 and all parts of netty to be shaded.

Clone this wiki locally