Very slow API response times for S3 when using dual stack on IPv6 only EC2 instance #4930
-
When making calls to S3 using the Java SDK v2 on an EC2 instance that doesn't have a public IPv4 IP, but have IPv6 working, using dual-stack mode, the first API call takes 16 seconds. If the client is reused within 5 seconds those calls are quick (~20ms). But if that client idles for more than 5 seconds, the next API call takes 16 seconds again. It looks like the SDK first tries using IPv4 3 times with a 5 second timeout, and then switches to IPv6. If I use curl to access the dual stack S3 endpoint I get an immediate response. Same of course if I force curl to use IPv6 with curl -6. But it will of course fail using curl -4. What might be wrong here? I'm basically using the AWS SDK for Java dual-stack endpoint example at https://docs.aws.amazon.com/AmazonS3/latest/userguide/dual-stack-endpoints.html but rewritten for SDK v2, with v2.24.2 of the SDK and Java 21. I've also tried Java 8 and Java 17 with the same results. It's an Arm based Ubuntu machine in us-east-1. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
That is weird, indeed. Can you share any logs of this? |
Beta Was this translation helpful? Give feedback.
Did some research, and you need to tell your JVM to prefer IPv6:
Can you try using the system property
-Djava.net.preferIPv6Addresses=true
and see if it works?