Skip to content

AwsDefaultClientBuilder.mergeChildDefaults() instantiates DefaultCredentialsProvider which is expensive #749

Closed
@stuartleylandcole

Description

@stuartleylandcole

Expected Behavior

Specifying a AwsCredentialsProvider on a service client should avoid the need to create an instance of DefaultCredentialsProvider, which in turn creates 5 implementations of AwsCredentialsProvider as part of the chain.

Current Behavior

If I've understood the code correctly, I think the reasoning for the current behaviour is to create a config with the defaults then merge this with any user-supplied configuration, resulting in a properly configured object. The code path for this is:

  • (In user code) DynamoDbClient.builder().build()
    • software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.syncClientConfiguration()
      • software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.mergeChildDefaults(SdkClientConfiguration)
        • software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider.create()

Possible Solution

I wonder if it's possible to add the user configuration first, and only add defaults for any properties not provided by the user? I guess this would be a change in software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.syncClientConfiguration()

Steps to Reproduce (for bugs)

The following code will take you down the code path I highlighted above

DynamoDbClient.builder().build()

Context

I am using the SDK in a Lambda which CRUDs data in a DynamoDB table. The Lambdas provide the API for my client so need to be responsive; creating the DynamoDbClient is by far the slowest part of starting my Lambda (provisioning aside, which I can't control) and this is one of the slowest parts as best I can tell from stepping through the code. Populating the Partitions object from endpoints.json is also slow but that is captured in #748

Your Environment

  • AWS Java SDK version used: 2.0.0-preview-12
  • JDK version used: 8 (provided by AWS Lambda)
  • Operating System and version: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions