Skip to content

Conversation

@sundersc
Copy link

Optimize AppSync Function Hotswap Performance

This commit addresses a performance bottleneck in the AppSync function hotswap mechanism by reducing redundant API calls.

Previous Behavior:
The hotswap feature was invoking listFunctions separately for each AppSync function requiring an update. This approach led to excessive API requests and potential AWS AppSync throttling.

Improvements:

  • Eliminate repetitive API interactions
  • Enhance overall deployment efficiency
  • Reduce potential throttling risks

Resolves one of the root cause of aws-amplify/amplify-category-api#3159


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

auto-merge was automatically disabled February 24, 2025 18:10

Head branch was pushed to by a user without write access

Comment on lines +123 to +126
if (!functions.hasOwnProperty(sdkRequestObject.apiId)) {
functions[sdkRequestObject.apiId] = await sdk.appsync().listFunctions({ apiId: sdkRequestObject.apiId });
}
const { functionId } = functions[sdkRequestObject.apiId].find((fn) => fn.name === physicalName) ?? {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include a unit test that validates that:

  1. listFunctions is called with proper params when sdkRequestObject.apiId is not present
  2. listFunctions is NOT called when sdkRequestObject.apiId is present
    ?

@sundersc sundersc marked this pull request as draft February 25, 2025 01:20
@sundersc
Copy link
Author

I'm closing the PR. Based on more testing, this approach is not going to improve the performance. If there are multiple functions in a stack, all those functions are being hotswapped at the same time, so caching is not helping here.

I'm working with AppSync team to check if it is possible to support server side filtering for list-functions based on function name.

@sundersc sundersc closed this Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants