native-transports vs netty-tcnative (Forked Tomcat Native)

522 views
Skip to first unread message

Manikanta G

unread,
Apr 24, 2018, 12:48:26 PM4/24/18
to vert.x
Hi,

I'm a bit confused to understand difference/relation between Netty's native-transports (http://netty.io/wiki/native-transports.html) and netty-tcnative (http://netty.io/wiki/forked-tomcat-native.html), especially in regards to Vert.x usage.


As mentioned in vertx-core Java guide (https://vertx.io/docs/vertx-core/java/#_native_transports), one can enable native transport to get more TCP features and to get better network throughput - correct me if I'm wrong. To do so, we need to include netty-transport-native-epoll dependency, and enable it in Launch code, like below:


public class VertxLauncher extends Launcher {

private static final Logger LOG = LoggerFactory.getLogger(VertxLauncher.class);

public static void main(String[] args) {
new VertxLauncher().dispatch(args);
}

@Override
public void beforeStartingVertx(VertxOptions options) {
LOG.info("Starting application...");

options.setPreferNativeTransport(true);
}

@Override
public void afterStartingVertx(Vertx vertx) {
boolean usingNative = vertx.isNativeTransportEnabled();
LOG.info("Is running with native transport: {}", usingNative); // ----------> This is printing 'false' on Windows.
}
}



Netty has netty-tcnative module which brings the APR+OpenSSL/BoringSSL support for Windows as well. As mentioned in it's doc (http://netty.io/wiki/forked-tomcat-native.html#wiki-h2-5), if we set the SslProvider.OPENSSL, it'll use netty-tcnative. 

  SslContext sslContext =
    SslContextBuilder.forServer(certificate, privateKey)
                     .sslProvider(SslProvider.OPENSSL)
                     .build();


Question: What is the relation between these w.r.to Vert.x as doc mentions native transport. I thought netty-transport-native-epoll, which Vertx depends on for native transport, uses netty-tcnative internally. But I couldn't see the dependency on it. And vertx.isNativeTransportEnabled() is returning 'false' even I included both 'netty-tcnative-boringssl-static' and 'netty-transport-native-epoll'. As per Netty doc, 'netty-tcnative-boringssl-static' has native libs for Windows as well.

Thanks,
Manikanta G


Julien Viet

unread,
Apr 24, 2018, 1:56:50 PM4/24/18
to ve...@googlegroups.com
those are not related.

- native transport is about the Netty Channel implementation that use JNI for Epoll instead of Java NIO (that is also Epoll)
- tcnative is about the SslHandler used for TLS encryption that either uses JNI with OpenSSL or the JDK SSL implementation

you can make any combination of these.

Julien


--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/e3d742e2-0015-4740-bd82-caee1f831526%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Pog

unread,
Apr 25, 2018, 6:46:57 PM4/25/18
to vert.x
Actually I have a follow up question on that Julien,
I'm a bit confused about the native transport as well.
If both native transport (Linux) and NIO use epoll, why would I want/need to enable native transport? Is there anything I may get out of it? 

Thanks

Julien Viet

unread,
Apr 26, 2018, 6:46:13 AM4/26/18
to ve...@googlegroups.com
native epoll on linux gives you more socket options such as TCP_FAST_OPEN, TCP_QUICKACK, SO_REUSEPORT, etc...

not all are exposed in Vert.x for now but those are.


it can gives a significant improvements in some conditions.


Reply all
Reply to author
Forward
0 new messages