Lambda Flashcards

1
Q

Lambda pricing

A

pay per request and compute time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

how to improve lambda performance

A

increasing RAM of function improves cpu and network

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Lambda use cases

A
  • serverless cron
  • thumbnail creation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

cloudwatch event bridge w/ lambda

A
  • can create a cron job or codepipeline eventbridge rule
  • resource based policy allows access
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

lambda tracing

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

testing lambda containers locally

A

test the containers locally using the Lambda Runtime Interface Emulator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

lambda container uploaded to ECR

A

must be in the same account as (ECR and where you created the lambda)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Improve lambda latency stability

A

enable your function to scale without fluctuations in latency, use provisioned concurrency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

lambda reserved concurrency

A

To ensure that a function can always reach a certain level of concurrency, you can configure the function with reserved concurrency. When a function has reserved concurrency, no other function can use that concurrency. More importantly, reserved concurrency also limits the maximum concurrency for the function, and applies to the function as a whole, including versions and aliases.

You cannot configure Application Auto Scaling to manage Lambda reserved concurrency on a schedule.

17
Q

lambda layers

A

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