Lambda Flashcards
1
Q
Lambda pricing
A
pay per request and compute time
2
Q
how to improve lambda performance
A
increasing RAM of function improves cpu and network
3
Q
Lambda use cases
A
- serverless cron
- thumbnail creation
4
Q
lambda with ALB
A
- put lambda into target group. in alb, http converted into JSON
- multi header values - alb setting that sends query string parameters and headers as an array to lambda
5
Q
Asynchronous lambda
A
- events sent to event queue
- s3, sns, cloudwatch event bridge
- 2 retries = 3 tries total max
- **should be idempotent - if task is retried, the result should be the same
- can create DLQ for failed tasks
6
Q
cloudwatch event bridge w/ lambda
A
- can create a cron job or codepipeline eventbridge rule
- resource based policy allows access
7
Q
lambda Event Source Mapping
A
- sync
- requires an execution role to be created to read from other aws services
- best practice - create one execution role per function
- lambda has an execution role to read from other services
8
Q
lambda destinations
A
- dlq that includes failures AND successes
- async invocations - define destination for successful or failed event
- sqs, sns, lambda, eventbridge bus
- AWS recommends aws destinations instead of DLQ now
- event source mapping - send discarded event batches to destination
- sqs, sns
- async invocations - define destination for successful or failed event
9
Q
lambda tracing
A
10
Q
lambda networking
A
- by default, lambda is outside your vpc so it can’t access vpc resources like internal ELB, elasticache, etc.
- to deploy lambda in vpc - define vpc id, subnets, and security groups
- lambda will create an ENI - elastic network interface
- requires lambda vpc access execution role
- lambda in a public subnet does NOT have internet access or public IP
- use a NAT gateway / instance with lambda deployed in private subnet to give it pub access
11
Q
lambda configurations
A
- add more ram to get mroe vCPU credits
- timeout - default 3 seconds, max 15 minutes
- more than 15 minutes? use ecs, fargate, or ec2
12
Q
lambda concurrency
A
- reserved concurrency
- up to 50concurrent executions for all lambdas in your account
- can set ‘reserved concurrency’ to set limit for when to throttle
- throttle error
- sync invocation - throttle error 429
- async - retry automatically then go to DLQ
- cold start - cold is loaded and initialization time
- provisioned concurrency - concurrency is allocated in advance
- keep function warm - no cold start
13
Q
testing lambda containers locally
A
test the containers locally using the Lambda Runtime Interface Emulator.
14
Q
lambda container uploaded to ECR
A
must be in the same account as (ECR and where you created the lambda)
15
Q
Improve lambda latency stability
A
enable your function to scale without fluctuations in latency, use provisioned concurrency