Serverless Flashcards
Serverless
*No infrastructure to provision or manage
*No servers to provision, operate, or patch
*Scales automatically by unit of consumption, rather than by server unit
*Pay-for-value billing model (pay for the unit, rather than by server unit)
*Built-in availability and fault tolerance
*No need to architect for availability because it is built into the service
AWS Serverless Portfolio
1.Lambda
2. Fargate
- API Gateway
- S3
- DynamoDB
- Aurora Serverless
- Congnito
- SNS
- SQS
- Step Functions
- Kinesis
- Athena
API Gateway
Create an entry point for your applications.
*Process up to hundreds of thousands of concurrent API calls.
*Choose internet-facing or internal only.
Types of tasks API gateway handles
traffic management, authorization and access control,
monitoring, and API version management.
What are things you can do with API Gateway
With
API Gateway, you can do the following:
*Host and use multiple versions and stages of your APIs.
*Create and distribute API keys to developers.
*Use Signature Version 4 (SigV4) to authorize access to APIs.
*Use RESTful or WebSocket APIs.
Features of API Gateway
Creates a unified API frontend for multiple
microservices
Provides distributed denial of service (DDoS)
protection and throttling for your backend
Authenticates and authorizes requests to a backend
Throttles, meters, and monetizes API usage by
third-party developers
What detailed metrics can API Gateway send to CloudWatch
What other type of logging can you do with API Gateway
*Number of API calls
*Latency
*Integration latency
*HTTP 400 and 500 errors
You can also activate access logging to log who has accessed your API and how they accessed it.
Amazon SQS
Fully managed message queueing service
Stores messages until they are processed and deleted
Acts as a buffer between senders and receivers
What makes SQS a managed service
requires no administrative overhead
massive scale, processing billions of messages per day
stores all message queues and messages within a single, highly available AWS Region with multiple redundant Availability Zones
Unique access control features of SQS
Developers can securely share SQS queues anonymously or with specific AWS accounts. You can also restrict queue sharing by IP address and time of day.
Streaming Single Instruction Multiple Data (SIMD) Extensions (SSE)
Streaming Single Instruction Multiple Data (SIMD) Extensions (SSE) protects the contents of messages in SQS queues using keys managed in AWS KMS.
SIMD Extensions encrypts messages as soon as Amazon SQS receives them. The messages are stored in encrypted form, and Amazon SQS decrypts messages only when they are sent to an authorized consumer
SQS queue provides the following benefits
*Loose coupling – With Amazon SQS, you can decouple preprocessing steps from compute steps and postprocessing steps. Using asynchronous processing isolates the producer logic into its own component separate from the consumer logic.
*Failure tolerance – In the event of an application exception or transaction failure, the processing can be retried. Once the maximum number of retries is reached, SQS can redirect the message to dead-letter queue .
*Absorbs spikes – An Amazon SQS queue makes the system more resilient. The queue acts as a buffer to
absorb spikes in traffic. This gives your application additional time to complete scale-out actions. It is also cost effective because you don’t need to provision as much idle compute to absorb spikes.
dead-letter queue
dead-letter queue where you can reprocess or debug it later
messages that cannot be processed by the consumer queue
SQS use cases
*Work queues – Decouple components of a distributed application that might not all process the same amount of work simultaneously. You can choose a standard queue or a first-in-first-out (FIFO) queue depending on the requirements of your application.
*Buffering and batch operations – Add scalability and reliability to your architecture and smooth out
temporary volume spikes without losing messages or increasing latency.
*Request offloading – Move slow operations off of interactive request paths by enqueueing the request.
*Auto scaling instances – Use SQS queues to help determine the load on an application. When combined with auto scaling, you can scale the number of Amazon EC2 instances in or out, depending on the volume of traffic.
Amazon SQS offers two types of message queues.
Standard queues
FIFO queues
Standard queues
support at-least-once message delivery and provide best-effort ordering.
Messages are generally delivered in the same order in which they are sent. However, because of the highly distributed architecture, more than one copy of a message might be delivered out of order.
can handle an early unlimited number of API calls per second. You can use standard message queues if your application can process messages that arrive more than once and out of order.
FIFO queues
are designed to enhance messaging between applications when the order of operations and events
is critical or where duplicates can’t be tolerated.
FIFO queues also provide exactly-once processing, but have a limited number of API calls per second.
Visibility timeout
You can configure the SQS queue’s
visibility timeout setting to make that message invisible to other consumers for a period of time. This helps to prevent another consumer from processing the same message. The default visibility timeout is 30 seconds. The consumer deletes the message once it completes processing the message.
If the consumer fails to delete the message before the visibility timeout expires, it becomes visible to other consumers and can be processed again.
Short Polling
An SQS queue with short polling:
*Sends a response to the consumer immediately after receiving a request, providing a faster response
*Increases the number of responses and therefore costs
Used by default
Long Polling
An SQS queue with long polling:
*Does not return a response until at least one message arrives or the poll times out
*Provides less frequent responses but decreases costs
Type of polling available with SQS
Which is preferred and why
You can configure an Amazon SQS queue to use either short polling or long polling.
Depending on the frequency of messages arriving in your queue, many of the responses from a queue using short polling could just be reporting an empty queue. Unless your application requires an immediate response to its poll requests, long polling is the preferable option.
When should you not use message queues
Selecting specific messages -This can
lead to a scenario where there are messages in the queue that no one is polling for and are never consumed.
Large messages -reasonably sized messages (in the tens or hundreds of kilobytes). As message sizes grow, it’s best to use a dedicated storage system
Amazon
SNS
a web service that helps you to set up, operate, and send notifications from the cloud.
follows the publish subscribe(pub sub) messaging paradigm, with notifications being delivered to clients
using a push mechanism.
Describe SNS pub sub
a publisher sends a message to the topic.
Amazon SNS matches the topic to a list of subscribers for that topic, and delivers the message to each
subscriber.
Subscribers receive all messages published to their subscribed topics. All subscribers to a topic receive the same messages.
Does SNS support encryption, if so how, if not why not?
Amazon SNS supports encrypted topics. When you publish messages to encrypted topics, Amazon SNS uses AWS Key Management Service (AWS KMS) keys
to encrypt your messages.
Type of SNS subscribers
Email/Email J-SON
Mobile text messaging SMS
Mobile push notifications
HTTP/HTTPS
AWS Lambda
Amazon SQS
Kinesis Data Firehose
SNS use cases
You can receive immediate notification when an event occurs, such as a specific change to your AutoScaling group. (e.g. CloudWatch alarm notification)
You can push targeted news headlines to subscribers by email or SMS.
You can send notifications to an app, indicating that an update is available. (e.g. push notifications)
SNS Features
- Single published message
- No recall option
- HTTP or HTTPS retry
- Standard or FIFO topics
- Delivery Policy
- messages stored redundantly across multiple servers and data centers
SNS vs SQS
- Delivery mechanism
- Producer and consumer
- Distribution model
- SNS - Push (passive), SQS - Poll (active)
- SNS - pub/sub, SQS - send or recieve
- SNS - one to many, SQS - one to one
Amazon Kinesis Data Streams
Collect and store data streams for analytics.
Amazon Kinesis Data Firehose
Load data streams into AWS data stores. ETL
Amazon Managed Service for Apache Flink
Transform and analyze streaming data in real time.
Amazon Kinesis Video Streams
Collect and store video streams for analytics
What can Amazon Kinesis do?
Collect, process, and analyze data streams in real time
Ingest real time data
Query data streams in real time and build and run stream processing applications using standard SQL, Python, and Scala
What are components involved in Kinesis data streams solution?
Stream, Producer, Shards, Consumers
Kinesis Data Stream Producer
Producers put data records into Kinesis Data Streams
Kinesis Data Stream Shards
Shards hold real time, sequenced data
Each shard is a uniquely identified sequence of data records in a stream
Kinesis Data Stream Consumers
Consumers read from shards and process data
Kinesis Data Stream - Stream
Describe? Limit data stream can process?
Each stream contains a specified number of shards
stream can receive 1 MBps per shard
Each shard has a read limit of 2 MBps for the consumers
How does Kinesis Data Firehose work?
- Data producers send data.
2.Data can be batched and compressed before loading it into AWS.
3.Kinesis Data Firehose writes to the destination.
Kinesis Data Firehose destinations?
- Amazon S3
- Amazon Redshift
- Amazon OpenSearch Service
- any HTTP endpoint
- third party service providers (e.g. splunk, data dog)
Step Functions
Coordinates microservices using visual workflows
Permits you to step through the functions of your
application
Automatically initiates and tracks each step
Provides simple error catching and logging if a step fails
**Think Nifi
AWS Services that integrate with Step Functions
You can directly call API actions in Step Functions
and pass parameters to the APIs of these services.
*Compute services: Lambda, ECS, EKS and Fargate
*Database services: DynamoDB
*Messaging services: SNS and SQS
*Data processing and analytics services: Athena, AWS Batch, Glue, EMR, and Glue DataBrew
*Machine learning services: SageMaker
*APIs created by API Gateway
How do you write Step Functions
JSON-based Amazon States Language
What state types does Step Functions support
*Task - Do some work in your state machine
*Choice - Make a choice between different branches to run
*Fail or Succeed - Stop with a failure or success
*Pass - Pass its input to its output or inject some fixed data
*Wait - Provide a delay for a certain amount of time or until a specified time or date
*Parallel - Begin parallel branches
*Map - Dynamically iterate steps
What kind of workflows can be created with Step Functions?
Standard and Express
Standard Workflow Step Function
use the Standard workflow type for long running, durable, and auditable workflows
workflows can run for up to a year and you can access the full history of workflow activity for up to 90 days after a workflow completes
use an exactly once model, where your tasks and states are never run more than once unless you specify a Retry behavior
Express Workflow Step Function
use the Express workflow type for high volume, event
processing workloads (such as IoT data ingestion,
streaming data processing and transformation, and mobile application backends)
can run for up to five minutes
Express workflows use an at-least-once model, where there is a possibility that an execution might
be run more than once
- How long does Kinesis Data Streams store data? by default?
- What is the max size of data blob?
- Max put records?
- Max output?
- KDS stores data up to 365 days and by default 24 hours
- Max size of data blob (before base 64 encode) is 1MB
- 1000 per second per shard
- 2 mb per second per shard
Two modes of Kinesis Data Streams and how you are charged
On demand - no set # of shards, charged on what you use
Provisioned - specify # of shards and charged an hourly rate based on # of shards