Usage on AWS Lambda
tomgallagher opened this issue · 8 comments
This looks like a really handy library.
I was wondering how the binary install works.
Does the binary get fetched each time the lambda runs?
If so, isn't the lambda function going to be quite expensive in time resources if ffmpeg has to be installed each time the lambda runs?
Do you happen to know how long the process takes on average?
Thanks
Hello, the binary is installed when you run "npm install
", which is usually only done on first run, or "npm update
" when you want to update dependencies. I'm not too familiar with Lambda, but once it's installed, it should just be there, unless everything is installed every time? Otherwise, it's usually pretty fast, since there is no compiling etc.
Again, don't really know how Lambda does things, but if you can reuse already downloaded files there should not be a problem, but if it's rebuilding everything from scratch every time I guess it's doing that for everything else as well? In the second case, it would be the time for downloading the binary I guess, nothing else.
Never measured the time it takes, but it's pretty instant on a good network, whatever the time it takes for it to be downloaded from npmjs.org.
Hi - Thanks for getting back. I'm not sure either. I've just read that everything is uploaded when you create the Lambda function so it should be OK. It's hard to get a definitive answer but it seems the all the NPM packages are pre-installed.
If you try it out, please let me know the results, would be nice to have it documented.
Will do. I'll post what I discover here.
OK, so the first problem I can foresee is the binary location. If the file is installed into the node_modules directory, it's probably going to work, Otherwise I would have to install the binary into a location that is accessible from Lambda, like an S3 bucket and then refer to that somehow.
It is, and you should be able to get a working path to it from the library. However, it should be mentioned that if you are running on one OS only it might also be a better idea to simply download a binary (see README) and put it in the project manually. It depends on your needs.
The probably biggest motivations for this project is a) getting updates and b) being able to run the same code/projects on multiple operating systems. If you don't have those needs, you may not need this project. On the other hand, if it Just Works, it's also pretty handy. :)
OK that's good news. If it's in the node_modules directory then Lambda should be able to find the binary no problem. Once again, I'll get back if and when I've got it working.
OK. I'm here to report that your package works as expected on AWS Lambda, at least when testing locally. Optimizing FFmpeg on Lambda a whole different problem! Probably worth a blog post by someone somewhere...
But thanks!