3 Major Challenges of the Serverless Framework, and How to Overcome Them
As a new developer starting out with Serverless, I struggled to get started and wrap my head around the various moving parts of building a serverless application for the first time. The Serverless Framework was a tremendous help with this challenge — it abstracts away a lot of the details that come with provisioning and maintaining cloud resources, and helps you keep everything organized in a single YAML file.
However, there are a few drawbacks and major challenges that come with the framework. I’d like to highlight each of them in turn, and recommend ways to overcome them based upon what I’ve learned.
Tip #1: Detailed cloudwatch logging is your friend.
One of the major challenges many of the serverless developers I’ve spoken to have repeated the same problem when attempting to debug their application: the AWS console and cloudwatch logs are tricky to debug and peer into.
They look like this:
Due to this challenge, I’d recommend you add detailed logging to your app so you can gain a better understanding of what’s going on under the hood. Other tools like cloudtrail and dashbird are also very useful for digging into the issue.
Tip #2: Split multiple products into different services.
A common mistake I made when starting with Serverless for the first time was trying to cram all my lambdas into a single Serverless service. Although this makes sense when your application is small (less than 15 Lambda functions), it becomes much more challenging to maintain and the deployment times are much longer.
For best results and ease of use, split up your Serverless.yml files into different product areas.
Tip #3: Keep your Lambda sizes small and leverage Lambda layers whenever possible.
Lambda layers are a great way to keep the size of your functions small, making it faster to deploy and iterate on your code. Layers store common functionality in a single “layer” that can be reused across functions.
Overall, the Serverless Framework is a great tool and has plenty of benefits associated with it. Making sure to follow these tips will make your experience learning the framework and building with it much easier.