Part 1: Strategic Decision-Making: Understanding AWS Suite Of Messaging/Event Services

By | January 23, 2024

As technical leaders, understanding the landscape of AWS Messaging Services is pivotal in architecting robust and scalable cloud solutions. AWS offers a suite of messaging services, each with distinctive features and collaboration patterns, tailored for specific architectural needs. From SQS’s reliable message queuing to SNS’s dynamic pub/sub messaging, Kinesis’s real-time data streaming, and MSK’s high-throughput message handling, the choice of service profoundly impacts your system’s performance, reliability, scalability, and more importantly how to develop them.

In this part 1, Let’s embark on a deep dive into these services, unraveling their capabilities ensuring that your architectural decisions are both informed and strategic.

In Part 2, we will look at the scenarios they’re best suited for, starting with SQS.

Amazon SQS

Amazon SQS, Simple Queue Service, is a fully managed message queuing service from Amazon that stands as a cornerstone when implementing inter-component messaging in microservices, distributed, and serverless function-based systems.

Application Collaboration:

SQS introduces an asynchronous point-to-point communication model between two components. When components communicate via SQS, the producer component sends messages to the queue without needing to know about the consumer’s state or even its existence.

Consumers of a queue poll over HTTPS and pull/fetch messages from the queue when it’s ready to process them. This pull model allows for efficient message retrieval without the overhead of constant connection maintenance.

Message Lifecycle:

  • Message Retention: In SQS, messages are stored until they’re processed or until the message retention period expires. This period can be configured from 1 minute to 14 days, with the default being 4 days.
  • Visibility Timeout: After a consumer pulls a message, it’s invisible to other consumers for the duration of the visibility timeout. If it’s not deleted within this period, it becomes visible again, preventing message loss in case of processing failures.
  • Message Removal: Once a message is successfully processed, it must be explicitly deleted from the queue by the consumer. If not deleted, the message becomes visible again after the “visibility timeout” period expires. This mechanism helps in ensuring that no message is lost in case of processing failures.

Because of the message lifecycle of SQS, each queue can only have one consumer, depending on the queue type of course the consumer can be scaled and have the queue load balance the messages between processor instances.

Type of Queues

Amazon SQS offer two types of queues:

  • Standard Queues
  • FIFO Queues

The Key Differences are:

Order Preservation:

  • FIFO queues preserve the exact order of messages; only one consumer can process messages at a time in the order they are sent.
  • Standard queues do not ensure strict order and multiple consumers can process messages simultaneously, potentially leading to out-of-order processing.

Throughput:

  • Standard queues provide a higher throughput compared to FIFO queues.
  • FIFO queues are designed to ensure the order and uniqueness of messages, which can limit the rate at which messages are sent and processed.

Message Delivery:

  • Standard queues provide at least-once-delivery, meaning messages might occasionally be delivered more than once.
  • FIFO queues provide exact-once processing, ensuring each message is delivered once and remains available until a consumer processes and deletes it.

Comprehensive Overview of Amazon SQS Features and Benefits:

  1. High Throughput and Scalable Workload Management: SQS excels in handling a nearly unlimited number of messages and API calls per second (SendMessage, 'ReceiveMessage, ‘ and DeleteMessage). Its ability to scale automatically and process each buffered request independently ensures that the system can manage load increases or spikes smoothly, providing robust support for high-volume messaging scenarios.
  2. Enhanced System Reliability: By locking messages during processing, SQS ensures that multiple producers and consumers can operate simultaneously without message loss. Standard queues deliver messages at least once, while FIFO queues maintain strict order and guarantee exactly-once processing, enhancing operations’ overall reliability and integrity.
  3. Controlled Message Delivery and Timing: With features like Delay Queues, which enable delaying processing of all messages in a queue for a certain period of time, avliable for both standard and FIFO queues and the ablity when using a standard queue to set individual Message Timers per message, SQS allows you to fine-tune message delivery schedules.
  4. Optimized Message Retrieval and Processing: Long Polling and Batch Operations optimize the retrieval and processing of messages, minimizing unnecessary API calls and ensuring efficient communication between producers and consumers.
  5. Advanced Message Management and Customization: SQS supports unlimited queues and messages, and you can enrich messages with structured metadata. Customize queue behaviour to fit specific needs, such as integrating with Amazon S3 or Amazon DynamoDB for more significant messages, ensuring efficient handling of diverse message types and sizes.
  6. Robust Security and Access Management: With server-side encryption (SSE) and comprehensive IAM policies, SQS ensures that your message data remains secure and that only authorized entities can access your queues, maintaining the integrity and confidentiality of your communication channels.
  7. Guaranteed Message Durability and High Availability: Messages are redundantly stored across multiple servers and data centres, ensuring their durability and availability. SQS’s infrastructure is designed to provide high availability and reliability for both message production and consumption, even during unexpected traffic spikes or component failures.
  8. Seamless Integration with AWS Ecosystem: Leverage the power of AWS services by integrating SQS with AWS Lambda, Amazon SNS, and Amazon EC2, among others, to create flexible, scalable, and resilient applications that meet your evolving business needs.
  9. Workload Absorption During Traffic Spikes: SQS’s remarkable capacity to absorb workload spikes acts as a buffer, storing messages when traffic surges or when consumers are unavailable or slow in processing messages. This ensures producers can continue their operations seamlessly, maintaining system performance and responsiveness.

Summary

Amazon SQS emerges as a robust messaging solution within the AWS ecosystem, characterized by its exceptional scalability, reliability, and adaptability. It’s designed to facilitate secure, efficient, and seamless message handling, empowering your architecture to navigate and excel in the ever-evolving cloud computing landscape. SQS provides a broad feature set that fortifies your system’s communication, ensuring it remains robust, responsive, and adaptable.

However, it’s essential to acknowledge and address the potential drawbacks associated with SQS to leverage its capabilities fully:

  1. Latency Considerations: The inherent pull-based model of SQS might introduce latency due to the need for consumers to poll the queue for new messages actively. This aspect requires careful management of polling strategies to maintain system responsiveness.
  2. Message Ordering Complexity: While FIFO queues offer strict message ordering, Standard queues do not guarantee the exact sequence of message delivery. Applications may need additional mechanisms or logic to handle potential out-of-order messages, especially when order is paramount.
  3. Polling Costs: Depending on the polling method employed, particularly with long polling, cost implications might be related to the number of API requests made or the time spent waiting for messages to arrive in the queue.
  4. Queue Message Retention Because it is a queue it has the retention of one; once messages are deleted by processors or messages exceed the retention period set or the max 14 days, messages are deleted forever.

In conclusion, while Amazon SQS provides a robust framework for message queuing, ensuring a loosely coupled and highly scalable communication environment, it’s imperative to carefully evaluate and manage aspects like latency, message ordering, polling costs and message retention. By doing so, you can harness the full potential of SQS, enhancing the fault tolerance, resilience, and overall effectiveness of your system’s messaging capabilities.

We explore when, and not to use Amazon SQS in Part 2. 1

Amazon SNS

AWS SNS (Simple Notification Service) is a fully managed pub/sub messaging service from Amazon designed to provide highly scalable, flexible, and cost-effective communication between different components of an application. SNS is particularly adept at enabling real-time and event-driven architectures by broadcasting events to many subscribers, including serverless functions, email addresses, mobile devices, and more.

Application Collaboration

SNS introduces a publish/subscribe communication model, simplifying and decoupling the interaction between producers and consumers of messages. Producers publish messages to topics, which are logical access points and communication channels. Subscribers (such as HTTP endpoints, Lambda functions, email addresses, mobile devices, etc.) receive messages published to the topics they subscribe to.

Message Lifecycle

  • Message Publication: Producers publish events to SNS topics without worrying about the subscribers’ details, ensuring a decoupled system architecture.
  • Topic Subscription: Subscribers subscribe to topics and receive messages as per their selected protocol (email, SMS, HTTP/S endpoints, etc.). SNS manages these subscriptions, ensuring events are delivered promptly and accurately.
  • Message Delivery: SNS ensures reliable and scalable delivery of messages to all subscribers, supporting multiple protocols and managing retries and message delivery status.

SNS Features and Benefits

  1. Multi-Protocol Support: SNS supports a range of protocols, enabling comprehensive and diverse communication strategies. across both application-to-application (A2A) endpoints (Amazon SQS, Amazon Kinesis Data Firehose, AWS Lambda, HTTPS) and application-to-person (A2P) endpoints (SMS, mobile push and email).
  2. High Throughput and Scalability: SNS standard topics support a nearly unlimited number of events per second. And millions of subscriptions (12.5 Million) per topic.
  3. Fan-Out Architecture: SNS supports the fan-out pattern, enabling a single published events to be delivered to millions of subscribers across different services, ensuring parallel and timely processing.
  4. Message Filtering: Subscribers can filter and receive only the events that meet specific criteria, optimizing event processing and reducing unnecessary network traffic.
  5. Integration with AWS Ecosystem: SNS integrates seamlessly with other AWS services, allowing you to build complex, responsive, and reliable applications. This integration facilitates diverse workflows and event-driven architectures.
  6. Robust Security and Access Management: With comprehensive IAM policies and encryption options, SNS ensures secure message handling and controlled access to topics, maintaining communication integrity and data confidentiality.
  7. Durable Event Delivery: SNS makes best effort to deliver events through a multi-phased delivery policy. It includes immediate retries, and with jitter multiple delayed retries, and exponential backoff. Depending on the subscriber type, SNS retries up to 50 times within 6 hours for standard endpoints and over 100,000 times across 23 days for Amazon-managed services. Additionally, subscribers can specify an SNS Dead Letter Queue using Amazon SQS for undeliverable messages.
  8. Strict Message Ordering: Integrating Amazon SNS FIFO topics with SQS FIFO queues ensures precise event ordering and deduplication, which is essential for distributed applications needing real-time data consistency. While subscribing SQS standard queues to SNS FIFO topics provides approximate ordering and guaranteed delivery. However, the ordering comes at a cost. Therefore SNS FIFO has limitations: it supports only up to 300 events per second or 10 MB per second, with a maximum of 100 SQS queues per topic and 1000 per AWS account, compared to 12.5 million subscribers for standard topics.
  9. No Event Retention/Persistence: With SNS, there’s no event persistence; if a subscriber is unavailable or fails during processing, the message is not delivered and is lost.

Summary

Amazon SNS is a vital component within the AWS ecosystem, marked by its exceptional flexibility, scalability, and reliability. It’s crafted to facilitate efficient, secure, and versatile messaging, empowering your architecture to respond swiftly and effectively in a rapidly changing cloud environment. The extensive feature set of SNS strengthens your system’s communication capabilities, ensuring it remains dynamic, responsive, and adaptable.

However, it’s crucial to consider and mitigate potential challenges associated with SNS to utilize its benefits fully:

  1. Message Ordering: SNS does not inherently guarantee the order of message delivery when using protocols other than FIFO queues. Applications requiring strict message sequencing might need additional handling or architecture considerations.
  2. Message Retention: If a subscriber is not actively subscribed to a topic when a event arrives, the event won’t be delivered. This can lead to unsynchronized processes and potential data integrity issues, as services may miss crucial updates.
  3. Integration Complexity: Depending on the use case, integrating SNS with multiple subscriber types and managing diverse message formats can introduce complexity. Proper planning and management are essential to ensure seamless communication flows.

In conclusion, AWS SNS provides a powerful framework for pub/sub messaging, enabling a loosely coupled and highly adaptable communication environment. By thoughtfully addressing aspects like message ordering and cost management, you can maximize the potential of SNS, enhancing the responsiveness, agility, and overall effectiveness of your system’s messaging infrastructure.

Amazon Kinesis Collaboration

Kinesis is synonymous with real-time data processing, providing essential capabilities for rapid and ongoing data intake and analytics.

  • Robust Components and Processing Power:
    • Kinesis Data Streams: Specialises in capturing, storing, and processing data streams in real-time.
    • Kinesis Data Firehose: Streamlines the loading of streaming data into designated AWS data stores.
    • Kinesis Data Analytics: Offers powerful data stream processing and analysis using SQL or Apache Flink.
  • Flexible Data Retention and Access:
    • Maintains data for extended periods (up to 365 days), facilitating data reprocessing and retrospective analyses.
    • Enables concurrent data processing by multiple consumers, ensuring efficient and timely data handling.
  • Real-Time Data Streaming Prowess:
    • Empowers multiple producers to concurrently send data into a stream, while allowing simultaneous data processing by multiple consumers, making it a go-to solution for real-time analytics and monitoring applications.
    • Preserves data order within each shard, guaranteeing coherent and scalable data processing.
    • Seamlessly integrates with AWS analytics services, enabling sophisticated analytics and real-time insight derivation.

If you are finding this post insightful, then checkout the books I recommend after reading Books I have read and recommend

4. Amazon Managed Streaming for Apache Kafka (MSK) Collaboration

MSK combines the robustness of Apache Kafka with the convenience of a fully managed service, making it an ideal choice for large-scale data handling applications.

  • High Durability and Scalability:
    • Caters to high throughput demands, making it suitable for extensive data processing tasks like log aggregation, stream processing, and event sourcing.
    • Guarantees data durability and availability, ensuring a reliable data handling infrastructure.
  • Configurable Retention and Replay:
    • Offers adjustable retention policies based on time or size, providing flexibility in data storage and management.
    • Supports event/data replay, crucial for scenarios that necessitate event/data reprocessing or for new consumers requiring access to historical data.
  • Advanced Message Retention and Removal:
    • Retains data in topics for a configurable duration, catering to varied data storage and access needs.
    • Unlike SQS, Kafka within MSK doesn’t remove messages post-consumption. Instead, messages persist in topics until they meet the defined retention criteria, allowing multiple consumers to independently read and process the same data set.
  • Seamless Integration and Processing:
    • Offers excellent compatibility with various AWS services and third-party tools, enhancing flexibility in data stream processing and analysis.
    • Supports an array of use cases, ranging from intensive real-time analytics to high-volume data ingestion.
  • High-Throughput and Scalable Interactions:
    • Engineered for managing vast data volumes efficiently, MSK is the epitome of high-throughput data handling.
    • Provides a reliable and immutable data storage paradigm, where Kafka ensures data is not just stored but readily accessible for future processing.
    • Facilitates flexible producer-consumer relationships, accommodating diverse communication patterns and operational requirements.

Conclusion

In conclusion, the array of AWS Messaging Services, including SQS, SNS, Kinesis, and MSK, offers a robust toolkit for solving complex architectural challenges. Each service provides unique features and collaboration dynamics, making it crucial for architects, CTOs, development managers, and engineers to comprehend the nuances and strengths of each. Whether it’s ensuring reliable inter-component communication with SQS, broadcasting notifications with SNS, processing vast data streams in real-time with Kinesis, or handling high-throughput events with MSK, the correct alignment of service to use case is key. By thoughtfully integrating these services into your cloud architecture, you can build systems that are not only performant and scalable but also resilient and adaptable to evolving business needs. As you navigate through these choices, remember that the right AWS Messaging Service can be the cornerstone of a successful, future-ready solution.

Leave a Reply