I'm working on AWS Lambda with the java SDK provided by AWS. I need to get an object from an S3 bucket. I use an S3Client for it (with apache HTTP as custom configuration) Times are acceptable.
Now I'm looking to replace my S3Client by an S3AsyncClient (netty). I use custom configuration as explained in the AWS documentation.
I ve defined a StopWatch to count the full lambda processing time. I can see some improvement :
total time: 254.4 ms (from my StopWatch)
BUT AWS adds +/- 2250 ms of billing time!
16:34:22 END RequestId: 3a8a2313-f3c7-4933-85a3-2f18e8876364 16:34:22 REPORT RequestId: 3a8a2313-f3c7-4933-85a3-2f18e8876364 Duration: 2460.98 ms Billed Duration: 2500 ms
So I pay a lot more!
Where does this difference come from? I think that some netty/executor threads keep in WAITING STATE for while then AWS kills them ... But not sure about it ...
I have configured my executor service. At the end for my lambda I try to stop all threads by using an executor.shutdown(); But It doesn't change anything...
As S3AsyncClient the extends AutoCloseable I 've defined it in a try with resources statement.
I precise that it occurs at both cold / hot start.
Need some help to understand this behaviour ...?
Thank you