Serverless applications, due to their distributed nature, are often stuck having to reinvent the wheel.
While small utility scripts and functions are often easily instrumented and monitored, anything of a transactional nature will need to implement special code to provide developers with common tools like stack traces, atomicity, and other patterns that rely on a singular flow of control.
Implementing these same tools for every new serverless application can quickly grow tedious, and prove to be error-prone as the software evolves.
In this article we’ll explore some open-source serverless libraries that help solve many of these challenges. Leveraging these tools will give your developers the information they need to quickly troubleshoot, diagnose, and resolve any failures in your serverless application.
The first post in our open source serverless series covers our pick of the essential tools. Read it here.
While serverless applications have a number of benefits over traditional microservice-oriented approaches, these advantages come at the cost of complexity in implementation and maintenance. Many pain points are introduced when the infrastructure running your code has a limited lifespan. Some of these include:
One issue of serverless applications is that the temporary nature of the hardware makes control flow management a critical component of your architecture. This involves implementing systems that communicate with AWS services like S3 in a method that can emulate a synchronous call without relying upon continuous call context. In addition, many of these services have their own security, configuration, and communication requirements, resulting in a lot of code duplication across functions as you integrate each service into your larger architecture.
aioboto3 is a python package designed to address this concern. It combines the time-saving AWS SDK Boto 3 with aiobotocore, allowing your serverless functions to seamlessly and quickly communicate with other AWS services in an asynchronous fashion, abstracting away the attendant complexity of tracking the activity and execution across a dynamic architecture. Using aioboto3, you can asynchronously call S3, EC2, and many other services with a single line of application code and some configuration. This will allow your serverless application to behave more responsively, while giving you a means to track and maintain data integrity.
Serverless applications require bootstrapping specific tooling for each new collection of functions and service interactions. This includes having to read and forward based on correlation IDs, emitting and tracking logs when Lambda functions time out, and implementing security measures like obfuscation. While it’s possible to implement each of these services as the need arises, unless your application has very specific needs there is not going to be much of a difference between configurations for each application.
DAZN Lambda Powertools – a project of Lumigo Developer Advocate Yan Cui – is a powerful collection of tools, middleware, helper libraries, and AWS clients that ease the headaches of building serverless functions in AWS Lambda. While not a traditional SDK, DAZN Lambda Powertools combines multiple useful auxiliary applications, templates, utility functions, and general support middleware into a single interface that can be maintained through configuration stored alongside your application. This lets you quickly implement common tasks in your Lambda functions, speeding the development process and reducing the duplication of effort and complications to maintainability you’d encounter developing these solutions in-house.
AWS Serverless Express, similar to Lambda API, is a framework focused on giving your developers the tools they need to develop in familiar patterns that may not be strictly applicable to the canonical concept of a serverless function. It’s built to run your Node.js application in a serverless context, with built-in Express.js support to ensure your developers are as productive building their REST APIs serverlessly as they are when building traditional microservice applications. Simply add a few proxies in API Gateway, and your application is up and running in AWS Lambda.
As serverless technology matures, so do the development pipelines and processes that surround it. While serverless function platforms like AWS Lambda are powerful tools that revolutionize application development when scaling functionality, the nature of how serverless platforms operate introduces many unique challenges that would not be present in a traditional web application.
The open-source nature of serverless technology has given rise to a robust ecosystem of plugins, templates, and various tools that can prove critical in building a maintainable and dependable serverless toolchain.
Building upon these, many open-source developers are releasing frameworks and libraries that solve many of the various pain points of serverless development. You’ll find that by adopting some of these tools, you can quickly add familiar components to your serverless application, giving you the tools you need to quickly release and iterate on your application.