aws / aws-sdk-java-v2

The official AWS SDK for Java - Version 2
Apache License 2.0
2.2k stars 853 forks source link

Netty HTTP client blocking on DNS resolution #3629

Closed yanns closed 1 month ago

yanns commented 1 year ago

Describe the bug

Netty threads are being blocked when calling InetAddress.getByName (https://docs.oracle.com/javase/6/docs/api/java/net/InetAddress.html#getByName(java.lang.String))

Screenshot 2022-12-15 at 14 43 28

This impacts the scalability of the AWS java library.

Expected Behavior

Netty threads should not be blocked

Current Behavior

Netty threads are being blocked

Reproduction Steps

Using the NettyNioAsyncHttpClient

  val builder = NettyNioAsyncHttpClient.builder()
  val httpClient: SdkAsyncHttpClient = builder.build()

Possible Solution

A possible solution is to use netty-resolver-dns like in https://github.com/netty/netty/blob/4.1/example/src/main/java/io/netty/example/dns/tcp/TcpDnsClient.java

Additional Information/Context

No response

AWS Java SDK version used

2.18.35

JDK version used

17.0.5_8

Operating System and version

linux

martinKindall commented 1 year ago

Hi @yanns , which tool are you using to show the graphics you attached? Do you know if something similar may be used in intelliJ? I am interested in displaying the time spent in blocking calls just as you did.

yanns commented 1 year ago

The JVM is profiled with https://github.com/async-profiler/async-profiler. The profile file is then opened by JDK mission control where the screenshot is coming from.

martinKindall commented 1 year ago

Thanks @yanns, I installed JDK mission control and async-profiler and both work. I already took a flamegraph profile.

I am having issues reproducing your results though using the .jfr format for the profile output. I can see the stacktrace correctly but the profiler is not saving the "Total Blocked" time, here's my command

./profiler.sh -d 20 -i 5ms -f result3.jfr <PID>

Would you mind sharing your command? So I can compare the args you used. Thanks.

yanns commented 1 year ago

It's a long time ago, but I think I used the following flags: -e cpu,alloc,lock,itimer

debora-ito commented 1 month ago

Scanning through some old open issues, I believe this was addressed in PR https://github.com/aws/aws-sdk-java-v2/pull/3990, which added the useNonBlockingDnsResolver option to NettyNioAsyncHttpClient.

Closing this.

github-actions[bot] commented 1 month ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.