Section 11: Serverless Applications Flashcards
What is AWS Lambda?
AWS Lambda is a compute service that lets you run code without provisioning or managing servers.
What is Lambda max execution time?
Lambda max execution time is 15mins
Lambda benefits
Lambda benefits include:
* executes code only when needed and scale automatically
* no servers to manage
* millisecond billing
* integrates with almost all other AWS services
How to invoke Lambda function?
Synchronous:
* CLI, SDK, API Gateway
* Waits for the function to processs the event and then returns a response
* Error handling happens on client-side (retries, exponential backoff etc)
Asynchronous:
* S3, SNS, CloudWatch Evnets
* Event is queued for processing and a response is returned immediately
* Lambda retries up to 3 times
Event source mapping:
* SQS, Kinesis Data Streams, DynamoDB Streams
* Lambda does the polling (polls the source)
Application Intergration Services Overview
SQS (Simple Queue Service)
* Messaging queue, store and forward patterns.
* Use case: building distrubted / decoupled applications
SNS (Simple Notification Service)
* setup, operate and send notifiations from the cloud
* use case: send email notification when CloudWatch alarm is triggered
Step Functions
* Out-of-the-box coordingation of AWS service compeonts with visual workflow
* use case: order processing workflow
Simple Workflow Service
* need to support external processes or specialised execution logic
* use case: human-enabled workflows like an order fulfiilmentsystem or for proceduaral requests. Note: AWS reccomends using Step Function instead of this.
Amazon MQ
* message broker service for Apache Active My and Rabbit MQ
* use case: need a message queue that supports industry standard APIs and protocols. Migrate queues to AWS
Amazon Kenisis
* collect, process and analyise streaming data
* use case: collect data from IoT devices for later processing
What is AWS EventBridge?
EventBridge is a serverless service that uses events to connect application components together, making it easier for you to build scalable event-driven applications.
How does EventBridge work?
Event sources such as AWS services, custom apps or Saas app trigger an event. EventBridge processes the events on its event bus and using rules defined and then sends onto various destinations know as targets.
In short:
1. Event sources (e.g. EC2) trigger events (e.g. service terminated)
2. Events are then put onto the EventBridge event bus
3. Rules defined in the event bus then define how those events are sent outo various targets (other AWS services)
AWS API Gateway deployment types
Edge-optimised endpoint
* CloudFront (CDN) —> API Gateway
* reduced latency
Regional endpoint
* Services in same region —> API Gateway
* reduced latency for request that originate in the same region
* can configure your own CD and protect with WAF
Private endpoint
* Services in same VPC —> API Gateway
* securely expose your REST APIs only to other services within your VPC or connect via Direct Connect
Which services form the app-facing part of the AWS serverless infrastructure?
Lambda and API Gateway
Which of the following are NOT Amazon SNS transport protocols?
AWS Lambda
AWS Lambda is a supported subscriber but not a transport protocol.
How can you save cost when checking for messages on an Amazon SQS queue?
How can you save cost when checking for messages on an Amazon SQS queue?
Use long polling
Long polling uses fewer requests and reduces cost.
How can you scale Amazon SQS?
Add more queues
You scale SQS by creating more queues.
Note: you can not implement auto scaling using SQS.
What is the purpose of the SQS message visibility timeout?
To add resiliency in case a processor fails to complete a job
The visibility timeout helps with resiliency so if an application component processing a message fails to complete the job another one can retry it.
Which service requires application components to poll for new messages?
Amazon SQS
SQS is poll-based not push-based.