aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

EC2MetadataUtils is very slow after 1.11.678

Open kliakos opened this issue 4 years ago • 7 comments

On 1.11.678 release, the EC2CredentialsUtils was replaced with InstanceMetadataServiceResourceFetcher.

A call to EC2MetadataUtils.getInstanceInfo() which used to last a few milliseconds, now takes a few seconds! On 1.11.678 it takes 10 seconds to respond, while on 1.11.749 it is quite better, but still it takes 2 seconds.

Is this something related to Metadata Service Version 2, or the SDK itself? If this is by design the way it works and the latency issue can not be fixed, we should at least be given the option to use the v1 service via the SDK.

kliakos avatar Mar 25 '20 11:03 kliakos

Moreover, nothing was mentioned about this modification on the 1.11.678 release notes.

https://github.com/aws/aws-sdk-java/blob/master/CHANGELOG.md#111678-2019-11-19

kliakos avatar Mar 25 '20 11:03 kliakos

Tried aws-sdk-java-v2, but with no luck. Still the EC2MetadataUtils.getInstanceInfo() takes a second at least.

kliakos avatar Mar 25 '20 18:03 kliakos

Hi @kliakos yes, this is related to the Instance Metadata Service V2 change, we have multiple reports of increased latency when calling the new service. We've opened an internal ticket to the EC2 team behind the Metadata Service and they are investigating.

Not mentioning this change in the CHANGELOG was a miss in our part.

I'll update here when we hear back from the EC2 team.

debora-ito avatar Mar 25 '20 21:03 debora-ito

Hi! Any updates on this one? I'm also having intermittent latency issues (sometimes reaching the non-configurable 1sec read timeout) while the SDK is fetching credentials from IMDS.

ffeltrinelli avatar Feb 09 '21 16:02 ffeltrinelli

Has there been any improvement with this issue? I tried 1.12.189 and the latency seems to be around the area of ~1sec.

kliakos avatar Mar 31 '22 08:03 kliakos

Hi! I talked about this issue and described our custom solution in this article.

ffeltrinelli avatar Apr 08 '22 18:04 ffeltrinelli

Hi! I talked about this issue and described our custom solution in this article.

EC2MetadataUtils is just a getter-only util class with static methods. It doesn't accept an AWSCredentialsProvider, thus the solution of overriding it is not possible.

kliakos avatar Apr 16 '22 07:04 kliakos