AWS Lambda functions and VPCs

If you are using AWS, keep in mind that cold starts are much worse when running Lambda functions inside a VPC. The reason for this is that Lambda functions in a VPC are allocated an Elastic Network Interface (ENI) to access VPC resources such as databases. If you ran the example code Chapter 2, A Three-Tier Web Application Using REST and Chapter 3, A Three-Tier Web Application Pattern with GraphQL, you may have noticed that the first API call took several seconds. This initial lag is mainly because the Lambda functions needed access to the RDS instance inside of a VPC, which means the Lambda functions themselves are required to be inside the same VPC.

If at all possible, avoid putting Lambda functions inside ...

Get Serverless Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.