Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support native netty protocol as a runtime choice. #259

Closed
NiteshKant opened this issue Oct 28, 2014 · 1 comment
Closed

Support native netty protocol as a runtime choice. #259

NiteshKant opened this issue Oct 28, 2014 · 1 comment
Assignees
Milestone

Comments

@NiteshKant
Copy link
Member

Netty's native transport is available on linux, is more performant and has optimized memory footprint.
Since, it is a choice based on the OS, it will force people to write conditional code in the client and servers to flip the transport when available. On top of it, there would not be any standardization for an application owner to switch to native transports (when available and applicable for a client/server) if required.

RxNetty should provide a way to globally use native transport for an application via static method calls in RxNetty factory class. This setting should follow the following rules:

  • It should be considered when a server or client has not explicitly chosen a transport (via the channel and eventloop implementation).
  • If the transport implementation is applicable for that server/client. UDP is not supported by the native transport.
@NiteshKant NiteshKant self-assigned this Oct 28, 2014
@NiteshKant NiteshKant added this to the 0.3.16 milestone Oct 28, 2014
@NiteshKant
Copy link
Member Author

Release 0.3.16 adds this support.

There are two ways to use this feature.

Independent setting

One can use native transport per client/server by using the following template:

Server
       RxNetty.newHttpServerBuilder(8888, new RequestHandler<Object, Object>() {
            @Override
            public Observable<Void> handle(HttpServerRequest<Object> request, HttpServerResponse<Object> response) {
            return null;
            }
       })
         .channel(EpollServerSocketChannel.class)
         .eventLoop(new EpollEventLoopGroup());
      }
Client
     RxNetty.newHttpClientBuilder("localhost", 8888)
            .channel(EpollSocketChannel.class)
            .eventloop(new EpollEventLoopGroup());

Global setting

If it is required to globally turn on/off the use of native transport, RxNetty provides two methods:

Enable

RxNetty.useNativeTransportIfApplicable() Enables use of native transport wherever applicable (TCP/HTTP/Websockets client and servers)

Disable

RxNetty.disableNativeTransport() Disables the use of native transport. If any client/server explicitly uses the native transport, that is not effected.

Additional dependency

Since, this is using the native transport of netty it requires the binary for the OS, the application is intended to be used.
In order to get the OS specific binary for linux, one can use the following gradle dependency:

compile group:"io.netty", name:"netty-transport-native-epoll", version:"${netty_version}", classifier: 'linux-x86_64'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant