Skip to content

Native Transports

Mark Paluch edited this page Jun 13, 2020 · 5 revisions

Netty provides two platform-specific JNI transports:

  • epoll on Linux

  • 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 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>
  • MacOS 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 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