Lambda Scenarios, IAM and Limits
Lambda Scenarios
- Proxy to other backend services
- Lambda serves as the ACTUAL backend service (http calls – a new function is launched for each call)
- API Gateway is part of serverless apps.
- Define endpoints for backend services, security and versioning
API Gateway
IAM – Roles and Policies – vs. Access Keys and Passwords
- Who gets assigned a role? – A Service (or User) gets assigned a ‘ROLE’.
- Why Create a New Role?– This will avoid using passwords or access keys (Access keys are long-term credentials for an IAM user or the AWS account root user.)
- Attach a policy or policies to that role. (e.g. allow update of RDS / DynamoDB).
- Attach a logging policy – that allows the service to LOG information to AWS (logs:createLogGroup, createLogStream, PutLogEvents)
- Now, any service / user assigned that role will be able to do .
- We will create an S3 read access ROLE to be used by our service (Lambda Function)
Lambda Timeout – 15 minutes
/tmp storage limit – 512 MB
Max Concurrency Level – 1000
Max Layers – 5
Memory Allocation – 128 MB to 3,008 MB, in 64 MB increments.
Deployment package sizes
- 50 MB (zipped, for direct upload)
- 250 MB (unzipped, including layers)
- 3 MB (console editor)
Execution processes/threads – 1,024
AWS Lambda Layers
You can configure your Lambda function to pull in additional code and content in the form of layers. A layer is a ZIP archive that contains libraries, a custom runtime, or other dependencies. With layers, you can use libraries in your function without needing to include them in your deployment package.
Layers let you keep your deployment package small, which makes development easier. You can avoid errors that can occur when you install and package dependencies with your function code. For Node.js, Python, and Ruby functions, you can develop your function code in the Lambda console as long as you keep your deployment package under 3 MB.
Note
A function can use up to 5 layers at a time. The total unzipped size of the function and all layers can’t exceed the unzipped deployment package size limit of 250 MB.
Node.js and Express and RESTFul APIs
Tooling
- ES Lint – clean code
- nodemon
Event Loops
Event Emitter
Buffers
Streams
File Systems
Global Objects
Callbacks
Utility Modules
Scaling Applications – exec, spawn, fork
Packaging
-
– jx package index.js index
-
– JX Core – creates index.jxp and index.js
Leave a Reply