-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
AWS SDK exception - Too many open files and Unknown host #2458
Comments
"Too many open files" sounds like the connections are not being properly closed after use. Can you provide the full stacktrace? |
(1). Too many open files (2). Unknown host |
We doubt "Unknown host" was caused by "Too many open files". And "Too many open files" could also cause java.lang.NoClassDefFoundError |
@debora-ito Are you suggesting I close s3Object in finally block or try-with-resource block? Is that the correct way to close connections? |
(1) "Too many open files" seems related to the AWS Lambda limit for file descriptors like you mentioned. Closing the S3 object is good, and also double-check if you are closing other resources used in your lambda function like the InputStream. Another thing you can experiment on is to share the same S3 client instance between lambda invocations instead of creating a new client with every invocation - to know more about how this would work check the Lambda runtime lifecycle docs: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html#runtimes-lifecycle (2) The |
Thanks @debora-ito .
which cannot be shared between invocations because of different bucketName and key. So we still need to close s3Object nicely Let me know what you think. Thanks |
Closing resources in a finally block is a good practice in general. I'll go ahead and close this, as it seems this issue is caused by the Lambda hitting the file descriptors limit. Feel free to reach out if you have further questions. |
COMMENT VISIBILITY WARNINGComments on closed issues are hard for our team to see. |
Hello, may I know what's the problem with my code snippet inside an AWS Lambda?
This code throws SDK exception quite often (not always) if Lambda receives more intensive requests. "too many open files" or "Unknown host" issues are always shown as the root cause. We doubt that's caused by Lambda has run out of FDs. But how could it happen? We closed connection every time after got resources. Any idea on improvement?
The text was updated successfully, but these errors were encountered: