Serverless computing allows scalability from zero to practically infinity. Inside AWS, Lambda is the key service to run functions.
But while the code is in a familiar language, the runtime environment, the connected services, and the best practices are all different than in server-based architectures.
Learn how to write Javascript functions for the AWS Lambda environment.
Want a sneak peek? Sign up for free chapters here:
A Lambda function is just one piece of the serverless puzzle, as it needs other services to be useful. It can't even store its logs but sends them to a separate service inside AWS.
It gets its permissions via an IAM Role, puts its metrics and logs to CloudWatch and X-Ray, and integrates with API Gateway to provide an HTTP endpoint. S3 is the choice to store files, and for secret configuration values, you can use SSM Parameter Store.
A Lambda function integrates with these services in different ways and each of them brings complications to the mix. But a serverless success story depends on using the full ecosystem.
The serverless runtime environment is radically different than traditional, on-server, architectures. It brings the promise of infinite scalability, but also new problems to solve.
The problem of cold starts, the retrying model, the ephemeral local storage, and other properties of the Lambda model are all problems you need to be aware of to develop and deploy functions with success.
And it also affects how to write Javascript code to it, such as how best to initialize variables and how to use async/await.
This book has all the information to write Lambda functions in Javascript effectively. You'll learn:
...and more!
The Lambda execution model
Serverless functions
Limits
The cost model
At-least-once execution
Caching in /tmp
Cold start
Memory
Setup
Node versions
The Lambda permission model
How to define code
Inline code
File interpolation
Adding packages with npm
Handler argument
Programming model
Async handler
Async programming patterns
Background tasks
Input and output
The event object
The context object
Output
The AWS SDK
Pagination
Environment variables
Timeout
Cause of timeouts
Mitigating timeouts
AWS SDK timeouts
Promise-based timeout handling
Debugging
Logging
X-Ray
Custom segments
Other topics
Storing secrets
Using SSM
Caching
Cache time
HTTP API
OpenAPI backend
Request parameters
Special handlers
Express backend
Hey, I'm Tamás! I co-author the advancedweb.hu blog and if you're here there is a good chance you've already read some of my articles.
I'm a software developer focusing mostly on cloud computing and web technologies. I'm especially interested in how to handle edge cases to end up with dependable software.
One of my main focus is security and how each part affects the whole system. I'm an AWS-certified security specialist.
The book is available from these stores: