Pratik Pednekar
1 min readJun 21, 2022

--

Hi Connor,

Thanks for your valuable input. I agree with you on the first point, and dependency injection can be overkill for a tiny application. I would definitely avoid this if the lambda contains limited logic.

In my case, I had created a single NodeJS application for seven lambdas. This application had a good amount of logic and, as I had a C# background, I was looking for a way to use dependency injection and write C# style unit tests.
I could have written them as 7 separate apps with limited code and no DI, but I did not want to create 7 repositories.

Regarding your point on caching, although lambda is ephemeral, we need to look at the number of requests it will serve in its lifetime, and a bit of local caching will help us reduce response times.

Recently, I came across this article from AWS, guiding reuse of objects across multiple function invocations: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html

--

--

Pratik Pednekar
Pratik Pednekar

Written by Pratik Pednekar

Sr Software Development Engineer at McAfee

Responses (1)