Cloud computing behemoth Amazon Web Services, has pushed out an Extensions API for its Lambda serverless platform that lets developers write custom code to handle lifecycle events – such as when the environment starts, invokes functions, and shuts down.
AWS Lambda runs functions on demand. It works by firing up an execution environment when a function is called, with a choice of runtimes including various versions of Java, Node.js, Python, .NET and Ruby, or a custom runtime. The environment stays running while there are frequent function invocations, and shuts itself down if not required for a period.
The Extensions API allows developers to write code for the three phases of the Lambda lifecycle: the init phase, when the environment starts up; the invoke phase, when functions run; and the shutdown phase, when the environment closes down.
Extensions can run either internally on the execution runtime, for purposes such as instrumenting code, or externally as companion processes, for purposes such as fetching secrets and caching them in the execution environment.
Lambda customer Square, a provider of eCommerce tools, has described how it used the new API to write an extension in Go that improves function startup time by fetching secrets before the runtime starts, and reported around 30-40 per cent reduction in cold start time.
Extensions are ideal for monitoring function execution on Lambda, and the usual suspects – companies like AppDynamics, DataDog, New Relic and Splunk, which provide monitoring and alerting services – have been quick to use them to integrate with their tools. The newly published API opens up ways for developers to optimise and monitor Lambda deployments using custom code. Extensions are deployed using Lambda layers, a way of packaging function dependencies. The pricing model is the same as for Lambda itself, based on a combination of the number of requests served and the compute time consumed.
Separately, AWS has also previewed CloudWatch Lambda Insights, CloudWatch being its own monitoring service. A multi-function view "provides visibility into issues such as memory leaks or performance changes caused by new function versions". CloudWatch users can enable Lambda Insights with a single click in the AWS console, where it is called Enhanced Monitoring, or via other tools such as the command-line interface (CLI).
The Extensions API is another piece in making Lambda more manageable and complete. Monitoring provider Thundra, another company taking advantage of the new feature, remarked that the "Extensions API will help companies that complain about the limitations of serverless overcome those challenges."
Serverless is the "best abstraction for deploying software", according to some experts, with Lambda the most popular option, though Microsoft has its equivalent in Azure Functions and Google has Cloud Functions. ®