Episode 79
As promised in the last episode, today we are going to look into the messaging category of AWS services group. Messaging is sometimes considered a part of application services group, however in the console they make up separate list, so let’s treat them the same here. Since the last article about security was quite long, this one will be shorter (also, it’s summer, the birds are shining, the sun is chirping, the water is wet, so…).
AWS messaging currently consist of Simple Queue Service, Simple Notification Service and Simple Email Service. Everything looks simple, so let’s dive in.
Simple Queue Service
AWS SQS was the first web service ever introduced by Amazon. The year was 2004 and cloud computing was no quite yet there. SQS is a Message Queuing Service which is a Message Oriented Middleware (MOM), but in the cloud, instead of on premises. SQS allows to decouple system actors working in the producer – consumer model. Multiple producers can write to the queue while multiple consumers can pick up messages and process them. The queue act as a buffer in case of consumers are too slow and simplifies system scaling as the number of actors grow. Queue also act as a fail-safe mechanism in case of consumers failure. Messages can be stored for a period ranging from 1 minute to 14 days with 4 days being the default, so when consumers come back online, they can proceed with processing and no information is lost. Message size can be up to 256 kB, billed per 64 kB chunks, and we can put up to 10 messages in one request. First million chunks per month is free. Messages are guaranteed to be delivered at least once, but the order is not guaranteed. Thus, the system should be ready to handle duplicates as well as not to rely on order.
When the consumer picks up the message, the message is not deleted from the queue, but becomes invisible and the visibility timeout clock starts ticking. If the processing ends before the timeout, consumer deletes the message. If not, the message becomes visible again and can be picked up by another consumer instance. Default timeout is 30 seconds and can be extended up to 12 hours. Delay Queue is a queue where the messages are initially invisible for a set amount of time. Dead Letter Queue is a queue that receives messages that could not be processed. Long Polling is a mechanism that lets us avoid querying an empty queue for messages repetitively, and instead wait up to 20 seconds for any message to arrive, thus saving processing power on pointless requests while maintaining good latency. Each message has its own url, the queue url as well as receipt handler that is assigned upon picking up message from the queue. The handle is required to delete the message, so the message can’t be deleted before being picked up. We can also optionally specify metadata of our own choosing for the message.
Simple Notification Service
AWS SNS is a Notification Service. Instead of following producer – consumer model, it operates in publisher – subscriber paradigm. In place of queues, we have topics to which publishers push messages. Subscribes of the topics do not check if there is a message (poll), but are delivered the message automatically when it’s available (push). Messages can be delivered in many ways, configured per subscriber and topic, including AWS Lambda, WS SQS, HTTP and HTTPS protocols, email, sms or mobile push notification. SNS might be used to communicate with people, for example for marketing purposes, but also to distribute work to EC2 instances or other system components. A fanout scenario is the case where SNS message is sent multiple SQS queues, HTTP endpoints or others for parallel processing. Other common use case is delivering system alerts.
Simple Email Service
AWS SES is dedicated to sending and receiving emails. While SNS can use SES as a mean of notification delivery, SES itself is a generic email sending mechanism and offers more options in that regard, including custom header fields, support for multimedia formats and is not limited to 8192 characters as is the case with SNS message. SES supports Sender Policy Framework (SPF) and DomainKeys Identified Mail (DKIM). It has spam and malware filters, so clients sending stuff of dubious quality might be blocked. Nobody likes spammers, even if they are paying for the service.
Cloud, cloud everywhere…
That’s it about messaging on AWS. In the next episode, we will look at Application Services Group in more detail. I hope you are not yet bored to death by AWS, we are almost there. In the future, I’m going to tackle at AWS certifications topic too. I’m not a huge fan of paper, but those seem to be a bit useful at least and are amongst the most valuable on the programing market nowadays. There will be other stuff as well, don’t worry and stay tuned.
Images source:
2 responses to “Amazon Messaging Services”