Serverless 101 (ACG) Flashcards
What are three benefits of choosing Serverless?
Speed - Serverless enables you to build scalable applications quickly without managing any servers.
Low Cost - Serverless applications are event-driven and you are only charged when your code is executed.
AWS Handles the Heavy Lifting - You can focus on writing code and building your application instead of configuring servers.
What is Lambda?
Lambda takes care of everything required to run your code, including the runtime environment.
Serverless compute - Run your code in AWS without provisioning any servers.
Lambda is event-driven. True or False?
TRUE
Event-Driven
Lambda functions can be automatically triggered by other AWS services or called directly from any web/mobile app.
Triggered by Events
Events could be changes made to data in an S3 bucket/DynamoDB table.
Triggered by User Requests
You can use API Gateway to configure an HTTP endpoint allowing you to trigger your function at any time using an HTTP request.
What are six benefits of using Lambda?
Low Cost - Pay only when your code executes.
Continuous Scaling - Lambda scales automatically
Event-Driven - Lambda functions are triggered by an event or action.
Independent - Lambda functions are independent. Each event will trigger a single function.
Serverless Technology - Lambda, API Gateway, Dynamo DB, S3, SNS, SQS
Lambda Triggers - Be aware of the services that can trigger a lambda function.
What is an API?
Application Programming Interface
We use APIs to interact with web applications, and applications use APIs to communicate with each other.
What is API Gateway?
Publish, Maintain, and Monitor
API Gateway is a service which allows you to publish, maintain, monitor, and secure APIs at any scale
A Front Door
An API is like a front door for applications to access data, business logic, or functionality from your backend services, e.g., applications running on EC2, Lambda.
Supported API Types
RESTful APIs - are optimized for stateless, serverless workloads.
Websocket APIs - are for real-time, stateful communication, e.g., chat apps.
What are RESTful APIs?
- REpresentational State Transfer (REST)
- Optimized for serverless and web apps
- Stateless
- Supports JSON (key-value pairs)
You can throttle API Gateway. True or false?
TRUE
You can throttle API Gateway to prevent your application from being overloaded by too many requests.
Everything in API Gateway is logged to CloudWatch.
TRUE
Everything is logged to CloudWatch. For example, API calls, latencies, and errors.
Lambda Versions
When you create/upload a new version of your Lambda function, there is only one version: $LATEST.
You can create multiple versions of your function code and use aliases to reference the version you want to use as part of the ARN.
For example:
arn:aws:lambda:eu-west-2:738450006354:function:mylambda:$LATEST
arn: aws:lambda:eu-west-2:738450006354:function:mylambda:Test (version 1)
arn: aws:lambda:eu-west-2:738450006354:function:mylambda:Prod (version 2)
What is a concurrent execution limit for Lambda?
AWS built-in Lambda safety feature to limit the number of concurrent executions across all functions in a given region per account.
Default is 1,000 exceptions per second per region (TooManyRequestsException, HTTP Status Code: 429).
Able to request limit increase.
Reserved concurrency guarantees a set number of concurrent executions are always available for a critical lambda function.
By default, your lambda functions will not be able to access any resources within a VPC without some addtl. configuration. True or false?
TRUE
You need to allow the function to access your VPC using the following:
- Private subnet ID
- Security group ID (with required access)
- Lambda uses this info to setup ENIs (Elastic Network Interfaces) using an available IP from your private subnet.
CLI example:
aws lambda update-function-configuration –function-name MYFUNCTION –vpc-config SubnetIds=subnet-1122aabb,SecurityGroupIds=sg-51530134
What are Step Functions?
Step Functions provide a visual interface for serverless apps, which enables you to build and run serverless apps as a series of steps.
Each step in your app executes in order, as defined by your business logic.
The output of one step can be used by the next.
Step Functions do not automatically trigger and track each step. True or False?
FALSE
Step Functions automatically trigger and trace each step. The output of one step often the input to the next.
Step Functions logging is disabled by default. True or False?
FALSE
Step Functions log the state of each step, so if something goes wrong you can track the issue down.
Standard Workflows
Long-running (up to 1 year)
At-most-once (runs once).
Non-idempotent (they always cause a change in state).
Express Workflows
Short-lived (up to 5 min)
At-least-once.
Idempotent (can run more than once and not have addtl side effects).
Synchronous Express Workflows
The workflow must complete before the next step begins, e.g., confirm successful payment before sending an order.