Closed eahefnawy closed 8 years ago
Yes, keeping the codebase lean is important. It's like browser development. Also remember, if you use the aws-sdk
, that is already a huge codebase that needs to be initialized. Further, Node has many good packages that come with it. Like using http
instead of request
for making external http requests.
yeah that's what I thought. Thanks!
Just would like to add that lodash provides a way to do this by modularizing the library.
Following this pattern is particularly helpful:
// load the modern build
var _ = require('lodash');
// or a method category
var array = require('lodash/array');
// or a method (great for smaller builds with browserify/webpack)
var chunk = require('lodash/array/chunk');
Flattening dependencies can help out too, especially if the same package is used by many of your dependencies. See arifsetiawan/flatten.
Bottom line: Don't require()
more than you have to and don't include more than you need to in your lambda that gets uploaded, if your goal is to maximize performance.
@binoculars thanks a lot for pointing that out! I'll do that.
I've read in the docs that we need to minimize the code base of each Lambda to speed up booting and execution time. With that in mind, do you think that we need to be careful when it comes to using NPM modules? Cause most modules out there offer a complete solution with lots of features, while you only need one feature.
maybe skip node modules whenever possible, and instead writing our own custom code to minimize code and maximize performance? but again we don't want to reinvent the wheel!