Reputation: 2043
I recently started working on AWS Lambda using Java and I need to understand how to properly structure a project like this.
Should I only create a single project for all the lambda functions, or should I create a project for each ?
I am currently following the former, and have created 10 lambda functions in one project.
I have avoided the use of Spring Boot and Spring for quicker cold start, less dependencies and smaller memory footprint, but the .jar size is already 20 MB.
Am I following a normal pattern, or how can I improve my project structure (see image) ?
Explanation: I have put all handlers in a single project and of course AWS will point to different handlers for each function.
I also want to ask, is it good design to keep them together or should I have different projects/modules for each lambda. For instance: deleteUser, disableUser etc.
Please guide me to start.
Thanks
Upvotes: 1
Views: 1771
Reputation: 492
One project for all Lambda functions should be fine as, finally the Lambda Function will need to be configured to its respective Handler. Check this similar stackoverflow thread.
Is it feasible to create multiple Lambda functions (Java) in a jar
For Application Memory footprint, try to deploy the Lambda application and check the cold start times and memory footprint as, these 2 will determine your Lambda costs to an extent.
Frameworks like spring-boot tend to cause longer startup times.Other alternatives you could consider.
If your application logic is simple enough,avoid using any framework and just use core java.
Spring Cloud Function- You could consider this as a spring boot version for developing serverles applications(Ofcourse there is a lot more to it)
Try Quarks as, they claim to have far lesser memory footprint and application startup times.
Upvotes: 2