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

Netty: SslProvider.OPENSSL_REFCNT example #835

Open
onlynishant opened this issue Oct 17, 2023 · 0 comments
Open

Netty: SslProvider.OPENSSL_REFCNT example #835

onlynishant opened this issue Oct 17, 2023 · 0 comments

Comments

@onlynishant
Copy link

I am using netty-tcnative with SslProvider.OPENSSL provider. I see a warning msg in GC log analyzer about finalizers which I am suspecting is mostly because of it.

[Warning] At one point 25872 objects were queued for finalization. 
Using finalizers is not recommended as it can slow garbage collection and cause wasted space in the heap. 
Consider reviewing your application for occurrences of the finalize() method.

I see Netty provides another option SslProvider.OPENSSL_REFCNT which does not have finalizers and instead implements ReferenceCounted.

  • I am wondering if it is a drop-in replacement of SslProvider.OPENSSL or if it needs more changes.
  • Is it production ready? I see it is marked as @UnstableApi. Any known side effects or issues?
  • Does it perform better than SslProvider.OPENSSL for low latency high throughput system?
SslProvider provider = SslProvider.isAlpnSupported(SslProvider.OPENSSL) ? SslProvider.OPENSSL : SslProvider.JDK;
logger.info("SSL provider: {}", provider);
sslCtx = SslContextBuilder.forServer(keyManagerFactory)
    .sslProvider(provider)
    .ciphers(cypherList)
    .applicationProtocolConfig(new ApplicationProtocolConfig(
        Protocol.ALPN,
        SelectorFailureBehavior.NO_ADVERTISE,
        SelectedListenerFailureBehavior.ACCEPT,
        ApplicationProtocolNames.HTTP_1_1
    ))
    .sessionCacheSize(SSL_SESSION_CACHE_SIZE) // 1800 -> 30 mins
    .sessionTimeout(SSL_SESSION_CACHE_TIMEOUT_SECOND) // 1024 * 100 -> 1000_00 sessions
    .build();


// DefaultServerInitializer
public void initChannel(SocketChannel ch) {
...
if (sslContext != null) {
  pipeline.addLast(sslContext.newHandler(ch.alloc()));
}
...
}

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