Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Massive Event Loop Lag caused by VALIDATE_CREDENTIALS and readFileSync #3995

Closed
4 tasks done
nik-suri opened this issue Dec 25, 2021 · 4 comments
Closed
4 tasks done
Assignees
Labels
bug This issue is a bug. duplicate This issue is a duplicate. p3 This is a minor priority issue

Comments

@nik-suri
Copy link

nik-suri commented Dec 25, 2021

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
I have an application running on EC2 that consumes events from SQS, processes them, and publishes new events to another queue on SQS. When running this application using pm2 I noticed very large event loop lags (up to 500ms). After profiling and analyzing the flamegraph, I saw that the lag is caused by attempting to turn sqs.sendMessageBatch into a promise, using sqs.sendMessageBatch.promise(). These calls end up performing costly operations which appear to all be synchronous (including readFileSync, emitting events, and handleRequest).

I also see repeated calls to VALIDATE_CREDENTIALS, which leads to costly hashing operations. I have attached an IAM role to EC2 which gives me access to my other AWS services. After going through your sdk code I thought that directly passing in environment variables for my ACCESS/SECRET keys might help resolve the issue. However, this did not work either.

I have done some digging and found these two related issues:
#3926 -- running in EC2 results in repeated filesystem reads for getting the credentials.
aws/aws-sdk-go#2972 -- getting credentials from the EC2 role results in slowdowns.

Is the issue in the browser/Node.js?
Node.js

If on Node.js, are you running this on AWS Lambda?
No

Details of the browser/Node.js version
v17.2.0

SDK version number
2.1048.0

To Reproduce (observed behavior)

  1. Create SQS queue
  2. Begin publishing events to SQS queue
  3. View large event loop lag in pm2

Expected behavior
Publishing events to SQS using promises should result in async behavior, and should definitely not result in the synchronous bottlenecks seen below.

Screenshots
Screen Shot 2021-12-25 at 2 30 37 PM
Screen Shot 2021-12-25 at 12 17 20 AM

Additional context
Running on EC2. Have attempted to prevent repeated calls to VALIDATE_CREDENTIALS by removing the IAM role from my EC2 instance and passing in my ACCESS/SECRET keys as environment variables.

@nik-suri nik-suri added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 25, 2021
@dreamspider42
Copy link

Was there any action on this? We've been seeing lots of readFileSync as well and seem to be setting all the credentials explicitly.

@dreamspider42
Copy link

Wanted to leave an update it seems like this can be prevented if you are using aws-sdk version 2.683 or later along with either setting the environment variables: AWS_ENABLE_ENDPOINT_DISCOVERY or AWS_ENDPOINT_DISCOVERY_ENABLED to a value (either true or false). If it is undefined in the service config or the env var it attempts to look for a configuration file. Since it will return false in the event that file is not found, you can save yourself some unnecessary IO by setting it explicitly to false.

You can see the related code that triggers this process here:

function resolveEndpointDiscoveryConfig(request) {

@ajredniwja
Copy link
Contributor

@nik-suri apologies the issue fell out of queue, @dreamspider42 comment holds true. Will track the issue with #3926

@ajredniwja ajredniwja removed the needs-triage This issue or PR still needs to be triaged. label Aug 15, 2022
@RanVaknin RanVaknin added the p3 This is a minor priority issue label Mar 27, 2023
@aBurmeseDev aBurmeseDev self-assigned this Aug 21, 2024
@aBurmeseDev aBurmeseDev added the duplicate This issue is a duplicate. label Aug 21, 2024
@aBurmeseDev
Copy link
Contributor

Similar issue was reported here and our team member responded in this comment. Closing as duplicate.

@aBurmeseDev aBurmeseDev closed this as not planned Won't fix, can't repro, duplicate, stale Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. duplicate This issue is a duplicate. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

5 participants