Ch7. Integrating
Application Services
Contents
• SQS
• SNS
• Cognito
• API Gateway
• WebSockets in AWS
1. SQS (Simple Queue Service)
The problem of delivering a
letter
• Failed to find the recipient in time.

• lose the letter in the process.
Messaging services
• An intermediary that has the main responsibility of
delivering the message and guaranteeing the delivery.

• These systems are designed to provide a communication
buffer between distributed components.

• producers (senders) -> broker (queues) -> receivers
SQS
• Simple Queue Service (SQS,訊息佇列列服務)
Asynchrony
• send-and-forget (fire-and-forget) & store and forward (儲
存與轉發) approach.

• Can be used for batch processing (批次處理理) and
coordinating message processing in different schedules.

SQS can also be used for batch processing and coordinating message processing in
different schedules.
SQS
• SQS is designed with high scalability, availability, and
reliability.

• this service is vendor neutral.

• This service availability is achieved by storing every
received message in multiple availability zones.

• Allows multiple producers on the same queue and
multiple consumers on the same queue.
Security
• Transport Level Security (TLS)

• Encrypted with a unique cryptographic key

• IAM
Security - Encryption
Durability(持續性)
• Default: 4 days.

• Range: 1 minutes ~ 14 days
Multiple AZs & Weighted
Random Distribution
Queue Types
• Standard Queues:

• Unlimited Throughput

• At-Least-Once Delivery

• Best-Effort Ordering. (盡⼒力力按順序傳遞)

• FIFO Queues:

• High Throughput,

• Exactly-Once Processing

• First-In-First-Out Delivery.
Polling (輪輪詢)
• The way SQS retrieves messages depends on factors
such as the message volume (greater than 1,000) and the
polling (pooling) configuration specified at the message or
the queue level.

• Amazon SQS provides 2 kinds of polling to receive
messages from a queue:

• Short Polling (default)

• Long Polling
Short Polling (短輪輪詢)
• The ReceiveMessage request queries only a subset of
the servers (weighted random distribution) to find
messages that are available to include in the response.

• Amazon SQS sends the response right away, even if the
query found no messages.
Long Polling (長輪輪詢)
• The ReceiveMessage request queries all of the servers for
messages.

• Amazon SQS sends the response after it collects the
maximum number of messages for the response, or when
the ReceiveMessage polling wait time expires.

• Benefits:

• Minimize CPU client cycles and diminishing costs,
avoiding unnecessary requests to the service API.
Messaging patterns
• Queuing chain pattern(佇列列鏈表模式):

• Problem to Be Solved:

• A tendency for performance bottlenecks to result from
having the systems tightly linked to each other.

• Hard to recover when there has been a failure.

• Solution:

• Loosely coupling the systems by between systems using
queues, and then exchanging messages that transfer jobs.
• image source: http://en.clouddesignpattern.org/index.php/CDP:Queuing_Chain_Pattern
Messaging patterns
• Benefits:

• Use asynchronous processing to return responses
quickly.

• Structure the system through loose coupling of simple
processes.

• You can increase or decrease the number of instances.

• Robust to failure.
Messaging patterns
• Job observer Pattern:

• Problem to Be Solved:

• Unanticipatedly large load on the batch system.

• Solution:

• Use tool such as CloudWatch to monitor the volume
of job requests (the number of SQS messages), so
that the batch servers can be added or deleted
automatically as required.
• image source: http://en.clouddesignpattern.org/index.php/CDP:Job_Observer_Pattern
Messaging patterns
• Priority queue pattern:

• Problem:

• There are cases where a large number of batch jobs
may need processing, and where the the jobs may
need to be re-prioritized.

• Solution:

• A queue is used in controlling batch jobs. The queue
need only be provided with priority numbers. 
• source image: http://en.clouddesignpattern.org/index.php/CDP:Priority_Queue_Pattern
2. SNS (Simple Notification Service)
SNS
• Simple Notification Service (SNS) 

• A messaging service designed to work with publisher/
subscriber semantics by decoupling distributed system
components using an event model based on
asynchronous push messaging.

• Message:

• payload (can be encrypted) and attributes 

• Maximum limit of 256 KB
SNS
• Publisher:

• Produce and send a message to a topic.

• Topic:

• A logical access point and communication channel.

• Subscribers:

• Consume or receive the message or notification over
one of the supported protocols (e.g. SNS) when they
are subscribed to the topic.
SNS
• 1 to N (one to many)
image source:https://aws.amazon.com/pub-sub-messaging/
SNS
• Messages will be delivered to all the channel's
subscribers, and subscribers who arrive late will lose their
sent messages.

• This kind of messaging is excellent for orchestrating
communications between micro services, and every
listening party chooses to process the message of drop it.

• Once a message has been sent, it cannot be sent again.
SNS
• Fanout (the number of inputs that can be connected to a
specified output) 廣播模式:

• A single published message can be copied on to
multiple destinations
SNS
3. Cognito
Cognito
• Amazon Cognito provides authentication (認證),
authorization (授權), and user management for your web
and mobile apps.

• Your users can sign in directly with a user name and
password, or through a third party such as Facebook,
Amazon, Google or Apple.
Cognito
• Federation Identity (⾝身分識別聯聯盟):

• Use existing credentials in multiple authentication facades

• 1. Cognito user pools:

• A serverless managed database that you can use to
authenticate your web and mobile apps.

• 2. Cognito identity pools:

• Enable you to grant your users access to other AWS services.
You can use identity pools and user pools separately or
together.
Cognito
• Cognito user pools:

• Signing up and signing in

• Updating the user profile data via standard and custom
attributes

• Forgot password by providing challenges

• Token-based authentication for JSON Web Tokens
(JWTs)

• Email and SMS two-factor verification
Cognito
• image source: https://www.notsosecure.com/hacking-
aws-cognito-misconfigurations/
4. API Gateway
API Gateway
• A service facade for RESTFul applications, the REST
architectural approach that integrates via web services.

• The API exposes a series of resources in a stateless
manner, and applications interact

with verbs (GET, POST, PUSH, DELETE), indicating the
server operation to be done.
API Gateway
API Gateway
API Gateway
• The endpoint can be configured with the following
scopes:
API Gateway
• The integration request can be made with one of the
following:

• Lambda function

• HTTP

• Mock

• AWS service

• VPC Link
5. WebSockets in AWS
WebSocket
• Provide bi-directional communication between the client and the
server to reach real-time applications:

• AWS IoT:

• A service designed to connect objects to the IoT via the SDK;
you can use the WebSockets via MQTT to push messages
back to the client.

• AWS AppSync:

• Supports the WebSockets protocol, and it can push
messages published to subscribers listening to specific
topics.
Resources
• 程式設計冪等設計:資料最終⼀一致性的保證

• Amazon SQS Queue Types

• Amazon SQS short and long polling

• CDP:Queuing Chain Pattern

• CDP:Job Observer Pattern

• What Is Amazon Cognito?

• WS-Federation⼆二三事
Thank You

AWS Study Group - Chapter 07 - Integrating Application Services [Solution Architect Associate Guide]

  • 1.
  • 2.
    Contents • SQS • SNS •Cognito • API Gateway • WebSockets in AWS
  • 3.
    1. SQS (SimpleQueue Service)
  • 4.
    The problem ofdelivering a letter • Failed to find the recipient in time. • lose the letter in the process.
  • 5.
    Messaging services • Anintermediary that has the main responsibility of delivering the message and guaranteeing the delivery. • These systems are designed to provide a communication buffer between distributed components. • producers (senders) -> broker (queues) -> receivers
  • 6.
    SQS • Simple QueueService (SQS,訊息佇列列服務)
  • 7.
    Asynchrony • send-and-forget (fire-and-forget)& store and forward (儲 存與轉發) approach. • Can be used for batch processing (批次處理理) and coordinating message processing in different schedules. SQS can also be used for batch processing and coordinating message processing in different schedules.
  • 8.
    SQS • SQS isdesigned with high scalability, availability, and reliability. • this service is vendor neutral. • This service availability is achieved by storing every received message in multiple availability zones. • Allows multiple producers on the same queue and multiple consumers on the same queue.
  • 9.
    Security • Transport LevelSecurity (TLS) • Encrypted with a unique cryptographic key • IAM
  • 10.
  • 11.
    Durability(持續性) • Default: 4days. • Range: 1 minutes ~ 14 days
  • 12.
    Multiple AZs &Weighted Random Distribution
  • 13.
    Queue Types • StandardQueues: • Unlimited Throughput • At-Least-Once Delivery • Best-Effort Ordering. (盡⼒力力按順序傳遞) • FIFO Queues: • High Throughput, • Exactly-Once Processing • First-In-First-Out Delivery.
  • 14.
    Polling (輪輪詢) • Theway SQS retrieves messages depends on factors such as the message volume (greater than 1,000) and the polling (pooling) configuration specified at the message or the queue level. • Amazon SQS provides 2 kinds of polling to receive messages from a queue: • Short Polling (default) • Long Polling
  • 15.
    Short Polling (短輪輪詢) •The ReceiveMessage request queries only a subset of the servers (weighted random distribution) to find messages that are available to include in the response. • Amazon SQS sends the response right away, even if the query found no messages.
  • 16.
    Long Polling (長輪輪詢) •The ReceiveMessage request queries all of the servers for messages. • Amazon SQS sends the response after it collects the maximum number of messages for the response, or when the ReceiveMessage polling wait time expires. • Benefits: • Minimize CPU client cycles and diminishing costs, avoiding unnecessary requests to the service API.
  • 17.
    Messaging patterns • Queuingchain pattern(佇列列鏈表模式): • Problem to Be Solved: • A tendency for performance bottlenecks to result from having the systems tightly linked to each other. • Hard to recover when there has been a failure. • Solution: • Loosely coupling the systems by between systems using queues, and then exchanging messages that transfer jobs.
  • 18.
    • image source:http://en.clouddesignpattern.org/index.php/CDP:Queuing_Chain_Pattern
  • 19.
    Messaging patterns • Benefits: •Use asynchronous processing to return responses quickly. • Structure the system through loose coupling of simple processes. • You can increase or decrease the number of instances. • Robust to failure.
  • 20.
    Messaging patterns • Jobobserver Pattern: • Problem to Be Solved: • Unanticipatedly large load on the batch system. • Solution: • Use tool such as CloudWatch to monitor the volume of job requests (the number of SQS messages), so that the batch servers can be added or deleted automatically as required.
  • 21.
    • image source:http://en.clouddesignpattern.org/index.php/CDP:Job_Observer_Pattern
  • 22.
    Messaging patterns • Priorityqueue pattern: • Problem: • There are cases where a large number of batch jobs may need processing, and where the the jobs may need to be re-prioritized. • Solution: • A queue is used in controlling batch jobs. The queue need only be provided with priority numbers. 
  • 23.
    • source image:http://en.clouddesignpattern.org/index.php/CDP:Priority_Queue_Pattern
  • 24.
    2. SNS (SimpleNotification Service)
  • 25.
    SNS • Simple NotificationService (SNS) • A messaging service designed to work with publisher/ subscriber semantics by decoupling distributed system components using an event model based on asynchronous push messaging. • Message: • payload (can be encrypted) and attributes • Maximum limit of 256 KB
  • 26.
    SNS • Publisher: • Produceand send a message to a topic. • Topic: • A logical access point and communication channel. • Subscribers: • Consume or receive the message or notification over one of the supported protocols (e.g. SNS) when they are subscribed to the topic.
  • 27.
    SNS • 1 toN (one to many) image source:https://aws.amazon.com/pub-sub-messaging/
  • 28.
    SNS • Messages willbe delivered to all the channel's subscribers, and subscribers who arrive late will lose their sent messages. • This kind of messaging is excellent for orchestrating communications between micro services, and every listening party chooses to process the message of drop it. • Once a message has been sent, it cannot be sent again.
  • 29.
    SNS • Fanout (thenumber of inputs that can be connected to a specified output) 廣播模式: • A single published message can be copied on to multiple destinations
  • 30.
  • 31.
  • 32.
    Cognito • Amazon Cognitoprovides authentication (認證), authorization (授權), and user management for your web and mobile apps. • Your users can sign in directly with a user name and password, or through a third party such as Facebook, Amazon, Google or Apple.
  • 33.
    Cognito • Federation Identity(⾝身分識別聯聯盟): • Use existing credentials in multiple authentication facades • 1. Cognito user pools: • A serverless managed database that you can use to authenticate your web and mobile apps. • 2. Cognito identity pools: • Enable you to grant your users access to other AWS services. You can use identity pools and user pools separately or together.
  • 34.
    Cognito • Cognito userpools: • Signing up and signing in • Updating the user profile data via standard and custom attributes • Forgot password by providing challenges • Token-based authentication for JSON Web Tokens (JWTs) • Email and SMS two-factor verification
  • 35.
    Cognito • image source:https://www.notsosecure.com/hacking- aws-cognito-misconfigurations/
  • 36.
  • 37.
    API Gateway • Aservice facade for RESTFul applications, the REST architectural approach that integrates via web services. • The API exposes a series of resources in a stateless manner, and applications interact
 with verbs (GET, POST, PUSH, DELETE), indicating the server operation to be done.
  • 38.
  • 39.
  • 40.
    API Gateway • Theendpoint can be configured with the following scopes:
  • 41.
    API Gateway • Theintegration request can be made with one of the following: • Lambda function • HTTP • Mock • AWS service • VPC Link
  • 42.
  • 43.
    WebSocket • Provide bi-directionalcommunication between the client and the server to reach real-time applications: • AWS IoT: • A service designed to connect objects to the IoT via the SDK; you can use the WebSockets via MQTT to push messages back to the client. • AWS AppSync: • Supports the WebSockets protocol, and it can push messages published to subscribers listening to specific topics.
  • 44.
    Resources • 程式設計冪等設計:資料最終⼀一致性的保證 • AmazonSQS Queue Types • Amazon SQS short and long polling • CDP:Queuing Chain Pattern • CDP:Job Observer Pattern • What Is Amazon Cognito? • WS-Federation⼆二三事
  • 45.