AWS Application Services
SNS (Simple Notification Service) is a service that automates the sending of email or text messages based on an event in your AWS account. It does this by working in conjunction with Cloudwatch to produce alarms when a certain threshold is exceeded, when there is downtime or a change in the environment. That alarm then prompts an SNS topic to be sent to the topic subscribers.
The supported channels are SQS, HTTP, HTTPS, Email, SMS, app notifications and Lambda.
A topic is a label or grouping of events. So you could have a topic called ‘EC2 failure’. The subscribed users (endpoints) of that topic will be the email address or phone number of your EC2 administrators. Note: a subscriber of an email notification must confirm / authorise their subscription before any notifications can be sent to them.
The publisher in SNS is the human, alarm or event that provides the message to the SNS topic.
SQS (Simple Queue Service) is a service that allows messages between servers to be queued. Once they arrive in a queue, the queue is polled by a worker instance rich reads & acts upon the message.
SQS lends itself to the deployment of decoupled applications.
Note: decoupled applications are those in which each component is independent of other components in the application. So, let’s say you have a website where users upload images and then those images are automatically processed to remove the background. You can decouple this application so that component 1 uploads the image and sends a message to an SQS queue. Component 2 then takes that message from the SQS queue and processes the background removal. In this instance, if component 1 failed, component 2 could continue to process messages in the queue & continue to apply effects to those queued jobs.
To handle loads during peak hours, autoscaling can be applied to a queue and the number of worker instances can also be scaled.
SQS is fully managed by AWS and is therefore highly available and redundant. AWS automatically backs up messages across multiple availability zones within a region.
- Long polling has fewer API requests & lower costs than short polling
- Each message can be up to 256kb in size
- SQS guarantees delivery of messages but does not guarantee the order they’ll arrive in.
- SQS does not guarantee the order messages are executed
- SQS does not guarantee that there will be no duplicate messages
SWF (Simple Workflow) is a fully managed workflow service which enables us to build distributed applications. It co-ordinates activities and can guarantee the order that tasks are executed (it also ensure no tasks are executed twice).
A workflow can run for up to 1 year and comprises of:
- Workflow: the sequence of steps to be completed
- Activities: the steps within the workflow
- Tasks: the things that interact with workers in the workflow. This can be an activity that needs to be completed or a decision that needs to be made
- Worker: the people or AWS resources that execute tasks
SWF is an ideal solution for order management through a website. It can manage everything from placing the order to payment to packing the order to delivery.