Lambda & Serverless Apps Flashcards
Explain the AWS Lambda Pricing structure?
- Pay per request and compute time (how long does the function run)
- Pay per calls
- Free tier of 1,000,000 AWS Lambda requests
- After the free tier you pay $0.20 per 1 million requests
- Pay per duration (in increments of 100ms)
- 400,000 GB/s of compute time = free
- == 400,000 seconds if function is 1 GB of RAM
- == 3,200,000 seconds if function is 128 MB RAM
- After that its $1.00 for 600,000 GB-seconds
How does lambda support multi-header values?
- There is a setting on the Application Load Balancer (ALB) that supports this function.
- When enabled, HTTP headers and query string parameters that are sent with multiple values are shown as arrays within the AWS lambda event and reponse objects.
What provides permission to invoke a function?
IAM Resource Policy
This is used when another SERVICE triggers the lambda fuction
What provides permissions for what a function can do?
IAM Execution Role
What are some recommendations for structuring your Lambda functions?
- Seperate business logic from the handle method
- Minimize the dependencies
What are some recommendations/best practices for managing serverless applications in AWS?
- Use a serverless application framework.
- Use a SAM template to deploy your serverless applications rather than creating a template in AWS CloudFormation.
What are some recommendations/best practices for organizing your code repository for serverless applications?
Organize your functions into services and give each service one deployment template and one code repository.
What are some reccommendation(s) / best practices for structuring your development environment for serverless applications?
- Create seperate AWS accounts for each developer if you have management processes in place to handle it.
- Seperate your production and non-production environemnts into different accounts.
What is the recommended test heirarchy for serverless applications?
- Local testing
- Remote integration tests
- Automated ntegration tests
What are some strategies for mocking out external services that your lambda function is talking to in order to isolate it and be able to test locally?
- Use an exisiting mock library project like DynamoDB local or LocalStack
- Create custom mocks
- Don’t mock - use actual services
Why would you use a custom mocking strategy to help unit test your lambda function?
- Allows you to effectively test Lambda functions chained together through multiple services
- Note: This is expensive (lots of work on devs part)
How can you debug your serverless application?
Use your IDE debugger on the Docker container provided by SAM CLI
What is the difference between a language and runtime in AWS lambda?
- The language is the specific language being used (i.e. Python, NodeJs etc) and runtime is the specifi version of that language.
- As a developer you need to be sure that the runtime is compatible with AWS lambda.
What are the size limitations of lambda?
- Uncompressed code and dependencies < 250 MB
- Compressed function package < 50 MB
- Total function packags in a region < 75 GB
What are some workarounds for Lambda size limitations?
- Look for smaller libraries.
- Look to break down your function further into smaller steps.
- A different language that offers a more compact solution.
What is the Ephemeral storage limitation of lambda?
- < 512 MB
- this is also refered to as the /tmp folder.
What is the maximum execution duration for a lambda function?
< 900 seconds (15 minutes)
What is the maximum number of concurrent lambda functions you can have?
- You are limited to running 1000 lambda functions @ the same time.
- Can set max limit to something lower using ‘reserved concurrency’ . This is recommended. When this limit is reached then throttling will occur.
What is Lambda @Edge?
- Used with CloudFront distribution
- Can modify requests coming from either user or origin