I am working on a project and created multiple lambda functions and now I am thinking about whether I made the correct decision to go this route.
Reasons I chose lambda:
- The App will have spiky traffic and almost no traffic at some times, so it is cost-effective
- It seemed like it would be less stressful to update particular functions because I know other functions are not touched and would not break the entire app (creates a setup similar to microservices)
- All APIs on my app are under timeout limits of lambdas so no long-running functions
Reasons I am doubting it now:
- It's difficult to share logic between lambdas like common utility functions and constants, I am using layers but that works fine if I don't have to update the layers too often as I have to upload it manually
- Version control : There is an option to create versions(it's like build tagging) but no easy way to actually create a repository and deploy on changes, this makes it difficult to check what could have gone wrong during a release. I could use AWS CodePipeline, CodeBuild and a trigger using EventBridge that produces SAM template and deploys to lambda using CloudFormation, this solution would work but I don't like how many applications it uses in between to achieve this. And not having version control will make the project unmanageable.
All this has made me think whether lambdas are not great if you have lots of functions and would be better off with a server that always runs and is tempting me to extract all function code and put it on a server. Lambdas are a no-brainer if you have few functions that would rarely run but is it practical to create full applications with multiple APIs?
Update: This question has received multiple good answers and it's either of these two
- Lambdas are not that great as people make it seem : I do agree with this now, when I was starting out it felt great as to how fast I was able to prototype and run things that can scale reasonably.
- Your CI/CD is not properly configured or use the serverless framework and all the problems could be solved : Well, this is also true as I also mentioned in my question on one of the possible ways to achieve this. But this does mean that Lambdas do not work for larger projects out of the box and you would need significant abstraction on top of it. Now that I think of it, I don't know why it didn't hit me earlier because it's so obvious now.
For now, I have decided to use lambdas initially and will eventually move the code to servers(because initially, lambdas won't even cost as much as a load balancer). For larger projects, I would say that lambdas are great for prototyping quickly or event-based background processes like step functions but if you have worked with servers before then you will be always questioning yourself when you start adding functions after another.