Youjun 04
Youjun 04
1 2
Permissions: Permissions:
• Access DynamoDB • Access DynamoDB + DAX
Security group
Global Tables is a
Multi-region, multi-
active database
Requirement Solution
Relational database running on MySQL Use Amazon RDS MySQL and configure
must be migrated to AWS and must be a Multi-AZ standby node for HA
highly available
Amazon RDS DB has high query traffic Create a Read Replica and configure the
that is causing performance application to use the reader endpoint
degradation for database queries
Requirement Solution
Amazon RDS database is unencrypted Encrypt a snapshot of the main DB and
and a cross-Region read replica must create a new encrypted DB instance
be created with encryption from the encrypted snapshot. Create a
encrypted cross-Region read replica
Requirement Solution
Aurora deployed and app in another Use Aurora Global Database and
Region requires read-only access with configure the app in the second Region
low latency – synchronization latency to use the reader endpoint
must also be minimized
Requirement Solution
Multi-threaded in-memory datastore Use Amazon ElastiCache Memcached
required for unstructured data
Requirement Solution
Serverless database required that Use Amazon DynamoDB
supports No-SQL key-value store
workload
Requirement Solution
Application requires a key-value Use DynamoDB Global Tables
database that can be written to from
multiple AWS Regions
Serverless Applications
eCommerce Application
User places an
order
eCommerce Application
User places an
order
eCommerce Application
eCommerce Application
Code is executed
Developer uploads
some code
Asynchronous:
• S3, SNS, CloudWatch Events etc.
• Lambda retries up to 3 times
• Processing must be idempotent (due to retries)
Function is
Function invocation executed
Lambda
Concurrency metrics:
• ConcurrentExecutions
• UnreservedConcurrentExecutions
• ProvisionedConcurrentExecutions
• ProvisionedConcurrencyInvocations
• ProvisionedConcurrencySpilloverInvocations
• ProvisionedConcurrencyUtilization
MyFunction:$LATEST Developer
This version is where
the code is edited
Lambda function
Ø When you're ready to publish a Lambda function you create a version (these
are numbered)
Ø Because different versions have unique ARNs this allows you to effectively
manage them for different environments like Production, Staging or
Development
Edit Code
Application code
points to the alias
MyFunction:$LATEST
Developer
Lambda function
Decoupled integration
Auto Scaling Group Auto Scaling Group
SQS Queue
Standard Queue
FIFO Queue
1 3 6 4
7 6 5 4 3 2 1
5 2 7 8
First-in, First-out
Delivery
Best-effort ordering
Ø The tag that specifies that a message belongs to a specific message group Messages
that belong to the same message group are guaranteed to be processed in a FIFO
manner
Ø The token used for deduplication of messages within the deduplication interval
1 3 6 4
5 2 7 8
Dead-Letter Queue
Ø A dead-letter queue lets you set aside and isolate messages that can’t be
processed correctly to determine why their processing didn’t succeed
Ø It is not a queue type, it is a standard or FIFO queue that has been specified as
a dead-letter queue in the configuration of another standard or FIFO queue
1 1 Message is visible
Producer
Delay Seconds
Timeline
Message cannot be
returned Message is
received
Lambda function
Default is 30 seconds,
max is 12 hours
SQS Queue
1 3
Producer 5 2
Ø SQS Short polling returns immediately (even if the message queue is empty)
Ø SQS Long polling can be enabled at the queue level or at the API level using
WaitTimeSeconds
Ø SQS Long polling is in effect when the Receive Message Wait Time is a value greater than 0
seconds and up to 20 seconds
DynamoDB Table
DynamoDB Stream
Item is written to
DynamoDB table
Manually add
message to queue
with AWS CLI
SQS triggers
Lambda
Manually add
Item is written to
message to queue
DynamoDB table
with AWS CLI
SQS Queue productVisitsDataHandler DynamoDB Table
CW Logs
Item-level
modifications
written to
DynamoDB Stream
DDB streams
S3 Data Lake productVisitsDatalakeLoadingHandler
Simple Queue Service Messaging queue; store and forward Building distributed / decoupled applications
patterns
Simple Notification Service Set up, operate, and send notifications Send email notification when CloudWatch alarm is
from the cloud triggered
Step Functions Out-of-the-box coordination of AWS Order processing workflow
service components with visual
workflow
Simple Workflow Service Need to support external processes or Human-enabled workflows like an order fulfilment
specialized execution logic system or for procedural requests
Lambda
Amazon Simple
Queue Service
HTTP/HTTPS
Amazon Simple Topic
Publisher Notification Service
Email/Email Web Application
-JSON
Email
SMS
Text
Check Yes/No
Create something
Wait
Send notification
Completed?
Check result
Ø You can quickly build and run state machines to execute the steps of your application
How it works:
1. Define the steps of your workflow in the JSON-based Amazon States Language.
The visual console automatically graphs each step in the order of execution
2. Start an execution to visualize and verify the steps of your application are
operating as intended. The console highlights the real-time status of each step
and provides a detailed history of every execution
3. AWS Step Functions operates and scales the steps of your application and
underlying compute for you to help ensure your application executes reliably
under increasing demand
As many consumers as you need Data is deleted after being consumed Publisher / subscriber model
Routes related records to same record Can have as many workers (consumers) as Integrates with SQS for fan-out
architecture pattern
processor you need
Multiple applications can access stream No ordering guarantee (except with FIFO Up to 10,000,000 subscribers
concurrently queues)
Can consume records in correct order at Individual message delay Data is not persisted
later time
Must provision throughput Dynamically scales No need to provision throughput
AWS Services
Custom Apps
Events
Targets
EventBridge
event bus
Event Target
EventBridge
event bus
Event Target
Private subnet
Key benefits:
Edge-optimized • Reduced latency for requests
endpoint from around the world
Amazon CloudFront Amazon API Gateway
VPC
Key benefits:
• Securely expose your REST APIs
Private endpoint only to other services within
Services in your VPC or connect via Direct
Amazon API Gateway
same VPC Connect
ANY
DELETE HTTP
GET HTTP_PROXY
HEAD LAMBDA
OPTIONS
PATCH LAMBDA_PROXY
Endpoint
Users Published API POST MOCK
PUT
Integration Request Lambda function, HTTP
Method Request
endpoint, EC2 instance,
AWS service etc.
HTTP STATUS
CODES CONVERT
RESPONSE PASSTHROUGH
BODIES
Map the status codes, headers,
Method Response Integration Response
and payload received from
backend into format for client
Ø Caching can reduce number of calls to the backend and improve latency of
requests to the API If not in the cache
(cache miss), go to
2 backend
1
Ø Limits:
Ø By default API Gateway limits the steady-state request rate to 10,000
requests per second
Ø The maximum concurrent requests is 5,000 requests across all APIs within an
AWS account
Ø If you go over 10,000 requests per second or 5,000 concurrent requests you
will receive a 429 Too Many Requests error response
Ø Upon catching such exceptions, the client can resubmit the failed requests in a
way that is rate limiting, while complying with the API Gateway throttling limits
THROTTLING: ENABLED
• RATE 10000
• BURST 5000
QUOTA: ENABLED
API Key • REQUESTS/M 1,000,000
THROTTLING: ENABLED
Endpoint
Basic Users • RATE 5000 Production v1 Stage
• BURST 2500
QUOTA: ENABLED
Users connect to specific • REQUESTS/M 500,000
public endpoint with API Can also configure per-
key that is configured in a method throttling limits
usage plan
S3 Static Website
DynamoDB Stream
DynamoDB Table
Requirement Solution
Application includes EC2 and RDS. Decouple EC2 and RDS database with
Spikes in traffic causing writes to be an SQS queue; use Lambda to process
dropped by RDS records in the queue
Migrate decoupled on-premises web Migrate to EC2 instances, SQS and EFS.
app. Users upload files and processing Use Auto Scaling and scale the
tier processes and stores in NFS file processing tier based on the SQS queue
system. Should scale dynamically length
Requirement Solution
API Gateway forwards streaming data Send the data to a Kinesis Data Stream
to AWS Lambda to process and and then configure Lambda to process
TooManyRequestsException is in batches
experienced
Migrating app with highly variable load Implement an Amazon SQS FIFO queue
to AWS. Must be decoupled and orders to preserve the record order
must be processed in the order they
are received
Requirement Solution
Objects uploaded to an S3 bucket must Create an event source notification to
be processed by AWS Lambda notify Lambda function to process new
objects
Requirement Solution
Lambda processes objects created in Configure reserved concurrency to set
bucket. Large volumes of objects can the maximum limit for the function.
be uploaded. Must ensure function Monitor critical functions’ CloudWatch
does not affect other critical functions alarms for the Throttles Lambda metric
EC2 instance processes images using Replace EC2 with AWS Lambda function
JavaScript code and stores in S3. Load
is highly variable. Need a more cost-
effective solution
Solutions Architect needs to update Create an Alias for the Lambda function
Lambda function code using canary and configure weights to Lambda
strategy; traffic should be routed based versions
on weights
Requirement Solution
App uses API Gateway regional REST Convert API to an edge-optimized API to
API. Just gone global and performance optimize for the global user base
has suffered
App uses API Gateway and Lambda. Throttle limit could be configured a
During busy periods many requests fail value that is too low. Increase the
multiple times before succeeding. No throttle limit
errors reported in Lambda
Need to ensure only authorized IAM Set authorization to AWS_IAM for API
users can access REST API on API Gateway method. Grant execute-
Gateway api:Invoke permissions in IAM policy
Website
Windows OS
Docker Engine
Hypervisor Windows OS
Server Server
Windows OS
Server
Order Account
Service Management
Payment Shipping
Service Service
Database
Linux OS
User 1
Monolithic Application
Linux OS
Load Balancer User 2
Linux OS
Order Account
Service Management
Payment Shipping
Service Service
Database
Shipping
Microservice
Order
Microservice
Docker Engine
Linux OS
Server
Use of Application Programming Interfaces (APIs) Easier integrations between application components;
assists with loose coupling
Speed and agility Fast to deploy and update. Easy to include high availability
and fault tolerance for each microservice
Task Definition
Auto Scaling group
{
"containerDefinitions": [
{ ECS Container ECS Container Amazon Elastic Container
"name": "wordpress",
"links": [ instance instance Registry
"mysql"
],
"image": "wordpress",
"essential": true, Registry
"portMappings": [
{
"containerPort": 80, Task Task Task Task
"hostPort": 80
}
An ECS Task is a
],
"memory": 500,
"cpu": 10
running Docker Image Image
Docker images can be
}
container
stored in Amazon ECR
ECS Service
AmazonEC2ContainerServiceforEC2Role
ECS Container instance The container instance
IAM role provides
permissions to the host
IAM Instance Role
Task
ECS Service
Task