Hello Adnan. Reading this at the beginning: "However, it could be as large as any Node.js application you have in production, and it would all work like a charm".
This could be exactly my case. I have been developing a backend using NodeJs, TypeORM, TypeScript, PostgreSQL and Typeorm. Could an entire backend project work as a LAMBDA function ? I have coded about 10%, desployed it as a single LAMBDA function and for now it works ok, but I'm afraid about how the node_modules is growing, because typeORM, sharp and aws-sd are big in size ...
Hey Victor! AWS Lambda does has its limits. Read more here. Long story short your deployment package, the .zip file needs to be under 50mb when you're uploading it directly. You can bypass this by uploading your .zip from S3 to Lambda. In that case the limit is 250mb. Read more here.
But, my advice for you here would be to create Lambda functions as microservices. Separate the logic within the application so you can distribute everything across multiple functions. Only use dependencies in places where they are needed, not across all functions. And, keep in mind AWS SDK is included in Lambda, you don't need to explicitly install it in the node_modules.
Check this tutorial out. It can help you understand how to structure your functions.
Thanks buddy. Your suggestions have been very useful. First thing i did was removing aws-sdk from node-modules and every thing has gone ok. Second i have just started breaking my backend into smaller parts proxied through the same API Gateway in AWS ... Everything alright so far. Thank you very much
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello Adnan. Reading this at the beginning: "However, it could be as large as any Node.js application you have in production, and it would all work like a charm".
This could be exactly my case. I have been developing a backend using NodeJs, TypeORM, TypeScript, PostgreSQL and Typeorm. Could an entire backend project work as a LAMBDA function ? I have coded about 10%, desployed it as a single LAMBDA function and for now it works ok, but I'm afraid about how the node_modules is growing, because typeORM, sharp and aws-sd are big in size ...
Hey Victor! AWS Lambda does has its limits. Read more here. Long story short your deployment package, the
.zip
file needs to be under 50mb when you're uploading it directly. You can bypass this by uploading your.zip
from S3 to Lambda. In that case the limit is 250mb. Read more here.But, my advice for you here would be to create Lambda functions as microservices. Separate the logic within the application so you can distribute everything across multiple functions. Only use dependencies in places where they are needed, not across all functions. And, keep in mind AWS SDK is included in Lambda, you don't need to explicitly install it in the
node_modules
.Check this tutorial out. It can help you understand how to structure your functions.
Good luck, and happy coding. :)
Thanks buddy. Your suggestions have been very useful. First thing i did was removing aws-sdk from node-modules and every thing has gone ok. Second i have just started breaking my backend into smaller parts proxied through the same API Gateway in AWS ... Everything alright so far. Thank you very much