Wednesday, 18 September 2019

Best practices for requiring libraries in AWS Lambda functions

I've been writing a decent number of AWS Lambda functions (specifically as managed by Netlify) and I have some concerns over code bloat from requiring external libraries. Obviously code bloat is always a concern, but it seems especially acute when you're paying per second and per MB of process RAM and you have to load all the libraries on every event instead of just at aserver start-up. My functions are generally something like digesting a webhook request, calling a few disparate APIs and then merging the results and maybe posting to another API or a database. Should I be overly concerned about the overhead of libraries like request/request-promise/axios, database clients or API-specific client libraries? Such libs will have tons of functionality that I'm not using in this little lambda function and it would be much trimmer to roll my own code to do only what I need. That said, maybe I'm overestimating how much overhead these libraries even add to the process. Is there any general consensus on best practices in this situation? If not, how do I go about benchmarking the code to decide if there even is a problem to address?

Submitted September 18, 2019 at 03:56PM by BloodAndTsundere

No comments:

Post a Comment