Skip to content

Remove ServiceMetadata from client creation and request paths to improve cold start - #7161

Open
S-Saranya1 wants to merge 10 commits into
masterfrom
feature/master/remove-service-metadata-usage
Open

Remove ServiceMetadata from client creation and request paths to improve cold start#7161
S-Saranya1 wants to merge 10 commits into
masterfrom
feature/master/remove-service-metadata-usage

Conversation

@S-Saranya1

@S-Saranya1 S-Saranya1 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

ServiceMetadata.of() triggers the static initialization of GeneratedServiceMetadataProvider, which eagerly instantiates all 307 service metadata classes, adding 350-500ms of cold start latency to every AWS client creation. This significantly impacts Lambda and latency-sensitive applications. The endpoint resolved by ServiceMetadata is ultimately replaced by Endpoints 2.0 at request time anyway, making this initialization cost entirely wasted.

This PR removes all internal SDK usages of ServiceMetadata from client creation and request-processing paths, replaces them with direct Endpoints 2.0 resolution, freezes ServiceMetadata class generation to the current 307 services via an allowlist and not generate ServiceMetadata classes for new services, and removes the base class fallback that was triggering the expensive initialization. Fixes #3664

List of all the PRs that are merged into feature branch

#7094 — Remove ServiceMetadata from AwsClientEndpointProvider in generated builders
#7105 — Remove ServiceMetadata from RDS/Neptune/DocDB presigning interceptors
#7110 — Remove ServiceMetadata from DefaultS3Presigner, S3Utilities, DefaultPollyPresigner
#7168 — Remove ServiceMetadata from HelpfulUnknownHostExceptionInterceptor
#7163 — Remove ServiceMetadata from signing region resolution
#7186 — Remove resolveClientEndpointProvider from AwsDefaultClientBuilder
#7185 - Stop generating Service Metadata Classes for new services

Modifications

  • Generated client builders: Replaced AwsClientEndpointProvider.build() (which called ServiceMetadata) with a 3-step approach: check overrides → resolve via service's Endpoints 2.0 provider → fall back to localhost placeholder for services with required request-bound params
  • RDS/Neptune/DocDB presigning interceptors: Replaced ServiceMetadata-based endpoint resolution with direct calls to each service's EndpointProvider
  • S3Presigner, S3Utilities, PollyPresigner: Use resolveFromOverrides() with localhost placeholder (S3) or direct EndpointProvider (Polly)
  • HelpfulUnknownHostExceptionInterceptor: Removed global-service detection logic (redundant with Endpoints 2.0 routing) and simplified to generic network error message
  • Signing region resolution: Codegen now resolves signing region from endpoint rules in generated builders, with fallback to client region in base class
  • ServiceMetadata allowlist: Froze generation at 307 services. New services use DefaultServiceMetadata (backed by partitions.json)
  • resolveClientEndpointProvider removal: Removed the base class fallback from AwsDefaultClientBuilder that was triggering ServiceMetadata initialization on every client creation. Added null validation with clear error message for version skew scenarios
  • Deprecated AwsClientEndpointProvider.build(): No longer needed, triggers expensive initialization
  • Test module: Replaced old-client-version-compatibility-test (pre-SRA 2.20.136) with service-client-backward-compat-test (S3 2.28.1, minimum supported version)

Testing

  • All existing unit tests pass across modified modules (aws-core, codegen, codegen-lite, s3, rds, neptune, docdb, polly)
  • Codegen golden files updated to reflect new CLIENT_ENDPOINT_PROVIDER and SIGNING_REGION resolution blocks
  • Added AwsClientEndpointProviderResolveFromOverridesTest — tests for resolveFromOverrides() covering override path, environment path, and empty result
  • Added signing region tests in DefaultAwsClientBuilderTest — verifies endpoint-rules-based resolution (AWS_GLOBAL → us-east-1) and fallback to client region on failure
  • Added DefaultPollyPresignerTest.presign_noEndpointOverride_usesDefaultEndpoint — verifies Endpoints 2.0 fallback produces correct host
  • Added test/service-client-backward-compat-test module — S3AnonymousTest, InterceptorSignerAttributeTest, S3OperationsTest verify old service client (2.28.1) works with new core (anonymous auth, interceptor/signer attributes, put/get, checksums, request-level credentials)
  • Existing presigning tests (RDS, Neptune, DocDB, S3, Polly) pass without modification, confirming behavioral equivalence

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

…ated client builders (#7094)

* Remove ServiceMetadata usage from AwsClientEndpointProvider in generated client builders

* Adding tests

* Additional changes

* Address PR comments
…eptors (#7105)

* Remove ServiceMetadata usage from RDS/Neptune/DocDB presigning interceptors

* Add tests
… DefaultPollyPresigner (#7110)

* Remove ServiceMetadata usage from DefaultS3Presigner, S3Utilities, and DefaultPollyPresigner

* Add tests and minor cleanup

* cache endpoint at construction time in DefaultPollyPresigner

* Address PR feedback

* update comments
@S-Saranya1
S-Saranya1 requested a review from a team as a code owner July 17, 2026 22:06
…erceptor (#7168)

* Remove ServiceMetadata dependency from HelpfulUnknownHostExceptionInterceptor
* Stop generating ServiceMetadata classes for new services

   Add service-metadata-allowlist.txt to freeze ServiceMetadata generation
   to the current 307 services. New services added to endpoints.json will
   not get ServiceMetadata classes generated. ServiceMetadataProviderGenerator
   no longer depends on Partitions/endpoints.json — takes the service list
   directly from the allowlist.

* Fix test failures

* Fix checkstyle

* fix fully-qualified class references

* Fix spotbugs

* Address PR feedback

* Remove test/region-testing module and add variant tests to PartitionServiceMetadataTest
)

* Remove resolveClientEndpointProvider from AwsDefaultClientBuilder

   This fallback method was triggering GeneratedServiceMetadataProvider
   initialization (~350ms) during every client creation because
   AttributeMap.build() eagerly resolves all lazy values including
   lazyOptionIfAbsent fallbacks. All generated clients have set
   CLIENT_ENDPOINT_PROVIDER themselves since SDK 2.27.16. Added null
   validation with clear error message for custom clients that don't
   set it

* fix tests

* update s3 depedency version in the old version compatibilty tests

* Update javadoc

* update javadoc

* Adress PR feedback

* Fix tests

* Replace old-client-version-compatibility-test with service-client-backward-compat-test

* Fix tests
@S-Saranya1 S-Saranya1 changed the title Remove service metadata usage Remove ServiceMetadata from client creation and request paths to improve cold start Jul 31, 2026
@S-Saranya1 S-Saranya1 added api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team perf-improvement Label for PRs that contain performance improvement changes. labels Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team perf-improvement Label for PRs that contain performance improvement changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Initializing GeneratedServiceMetadataProvider takes a while

2 participants