Hitesh Sahu
Hitesh SahuHitesh Sahu
  1. Home
  2. ›
  3. posts
  4. ›
  5. …

  6. ›
  7. 3.2 Streaming

Loading ⏳
Fetching content, this won’t take long…


💡 Did you know?

🐙 Octopuses have three hearts and blue blood.

🍪 This website uses cookies

No personal data is stored on our servers however third party tools Google Analytics cookies to measure traffic and improve your website experience. Learn more

Cover Image for AWS Streaming Resources (SQS, SNS, Kinesis, MQ)

AWS Streaming Resources (SQS, SNS, Kinesis, MQ)

Overview of available streaming services in AWS & when to use them

Hitesh Sahu
Written by Hitesh Sahu, a passionate developer and blogger.

Mon Sep 29 2025

Share This on

Cloud Integration

Application Communicate Pattern

  • Synchronous Communication: Bad pattern make it hard to decouple Application
    • Tightly Couple System: If one component fails it can failed Other component or other system Eg: Monolith Application
  • Asynchronous Communication: Use Event Base Queue to decouple Applications
    • Loosely Coupled System: Components talk to each other over message & Queue Eg Microservice

Services helping with communicating Loosely Coupled Components


Amazon Simple Queue Service (SQS)

Producer Store messages in Queue, Consumer Process the Message

  • This allows us to scale Producer Layer & Consumer layer independent of each other based on Messages in Queue

1. Standard queues

  • No Limit: Send, Store, Receive b/n component in any volume and any rate
  • SQS SDK is used to send message using SendMessage API
  • Fully Manged & Serverless
  • Unlimited Throughput
  • Low Latency < 10 mS
  • TTL: 4 days to 14 days
  • Size 256kB/Message encrypted in transit & rest using KMS
  • Consumer can poll upto 10 message at a time.
  • Consumer must delete message after processing.

Limitation;

  • Duplicate Messages
  • Out of order Messages

Security

  • In flight encryption using HTTPS
  • At rest encryption using KMS
  • IAM Policy to regulate Access to SQS API

API

SQS & ASG

  • Cloud watch alarm can be used to scale Consumer based on number of messages in Queue

SQS Request Response System

Use 1 request queue & many response queue to scale Consumer & producer.

  • Make use of ID to publish consumer result to a different queue.
  • SQS Temporary Queue Client: Can be used to simplify the process of creating & deleting queues

SQS Request Response System

SQS ACCESS Policy

JSON based document to control who can write/read Queue

  • Use Case: cross account access to poll messages or S3 Event Notification

SQS Message Visibility Timeout

When Message is polled by consumer it become invisible to other consumer within a timeout window.

  • Default: 30 Seconds
  • If message is not consumed within 30 Sec it will be visible to other consumer
  • ChangeMessageVisibility- API to request more time for message

DEAD LETTER QUEUE(DLQ)

Threshold for max read time for consumer failed to read message within Visibility Timeout

  • Retain in DLQ for 14 days to debug message

DELAY QUEUE

Set delay for message visible in SQS.

  • Delay can be upto 0-15 Minute in Delivery Delay

SQL Long Poling

Consumer Wait for Message to Arrive to reduce latency

  • Reduce number of time API call to SQS.
  • Time can be set from 1Sec -20 Sec
  • Reduce Latency

SQS Extended Client

Send Data beyond 256 kB message Limit

  • Use SQS Extended Library(Java Lib)
FeatureAmazon SQSApache Kafka
ModelMessage QueuingDistributed Event Streaming
ThroughputHigh, but limited (especially FIFO queues)Extremely high throughput
ScalabilityScales automatically, but limited by throughput in FIFOHorizontal scaling for large data streams
Message RetentionConfigurable (1 minute to 14 days)Configurable, long retention (months to years)
OrderingFIFO queues (guaranteed) or unordered (standard)Ordered within partitions, but not across partitions
LatencyHigher compared to KafkaLow latency, suitable for real-time use
ComplexitySimple to use, fully managedMore complex, requires management
CostPay per request and message volumeHigher operational costs for clusters, depending on scale
Use CasesSimple queuing, decoupling servicesReal-time streaming, event sourcing, log aggregation, analytics

2. SQS FIFO Queue

First in first out, Order is maintained & no duplicates

  • Limited Throughput 300/Msg with Batching 3000/Msg (send, receive, or delete operations per second)
  • The name of a FIFO queue must end with the .fifo suffix.
  • The suffix counts towards the 80-character queue name limit.

To Convert Standard Queue to FIFO: Delete existing Queue & Recreate it as FIFO Queue

Deduplication Interval

Time within which next duplicate message will be ignored

Methods to remove duplicate

  1. Content Based Deduplication: SHA256 Hash of message Body is compared
  2. Deduplication ID: Provide Explicit ID to compare duplicate

MessageGroupID

Create Order of messages within Group

  • 1 MessageGroupID = 1 Consumer
  • Order of message with GroupID is maintained
  • Order of group is not guaranteed

Standard vs FIFO Queue

FeatureStandard QueuesFIFO Queues
ThroughputNearly unlimited API calls per secondUp to 3,000 messages/sec with batching (or 300 API calls/sec)
OrderingBest-effort ordering (may arrive out of order)First-in-first-out (FIFO) ordering within message groups
Delivery GuaranteeAt-least-once delivery (messages may be duplicated)Exactly-once processing (deduplication supported)
Use Case: High VolumeIdeal for real-time data streaming, background jobs, large-scale appsSuitable for sequential processing when message order matters
Use Case: Task AllocationDistribute tasks to multiple worker nodes efficientlyEnsure commands execute in order (e.g., financial transactions)
Use Case: Data ProcessingBatch messages for database processingProcess product price updates in correct order
DurabilityStored across multiple AWS Availability ZonesStored across multiple AWS Availability Zones
ScalabilityHighly scalable (scales automatically)Can be scaled with high throughput mode (up to 30,000 TPS)
DeduplicationNot supported (handle duplicates at the application level)Supported via MessageDeduplicationId or content-based deduplication
LatencyLow latencySlightly higher latency due to ordering guarantees

Amazon Simple Notification Service (SNS)

One to many relationship. Send message to many Consumers on SNS Topic.

  • Send Notification along with messages over Pub/Sub Model in a topic
  • End user can subscribe to different Channel to get message for relevant topics
  • No Limit: 10 Million sub/topic, 100k topics

Producer:

  • S3 Bucket Events
  • ASG
  • CloudWatch Alarm
  • Cloudformation Template State Change

Subscriber :

  • SQS Queue
  • Lambda Function
  • HTTP/HTTPS End Point
  • Push Notification SMS, email

Security

  • HTTPS: In flight encryption
  • KMS: At rest encryption
  • IAM Policy to regulate Access to SQS API
  • SNS Access Policy: Limit who can write to SNS & cross account access

FAN OUT PATTERN

Push Once in SNS+ Subscribe to many SQS

  • Fully decoupled and avoid data loss in SNS
  • SQS Access Policy must allow to write from SNS
  • SQS allow no data loss, retries, delay processing
  • Use case: S3 Event to distribute to many SQS queue

SNS FIFO

Same as SQS Fifo to allow Fan out +Ordering+ de duplication.

  • Ordering by Message Group ID
  • Deduplicate using deduplicate ID
  • Can Only have SQS FIFO Queue as subscribers

SNS FILTER POLICY

JSON Policy to Filter out SNS messages to different SQS in Fan out pattern

  • Without FIlter Policy Subscriber will receive all messages

SQS vs SNS vs MQ

FeatureAmazon SQSAmazon SNSAmazon MQ
TypeMessage QueuePub/Sub (Publish-Subscribe)Managed Message Broker
Use CaseDecoupling microservices, job processingEvent notifications, broadcasting messagesLegacy system integration (ActiveMQ, RabbitMQ, IBM MQ, etc.)
Message DeliveryMessages are pulled by consumersMessages are pushed to subscribersSupports both queues and topics (Pub/Sub)
OrderingFIFO (Guaranteed) or Standard (Unordered)No guaranteed ordering (FIFO via SNS+SQS)Supports message ordering (depends on broker)
DurabilityStores messages for up to 14 daysNo message persistenceMessage persistence based on broker configuration
LatencyLow to moderateLowLow
ScalabilityHighly scalableHighly scalableModerate scalability
Protocol SupportREST API, SDKsHTTP, Email, SMS, SQS, LambdaAMQP, MQTT, STOMP, OpenWire, JMS

Amazon MQ (Managed Apache ActiveMQ)

Manged Queue system to use existing queue structure instead of SQS

  • Run open protocol :MQTT, AMQP, STOMP,Open Wire, WSS
  • Does not scale like SQS
  • Not serverless: runs on dedicated Machine
  • Have both SQS & SNS

Kafka vs. RabbitMQ: Key Differences

Architectural Differences

FeatureKafkaRabbitMQ
ArchitecturePartition-based design for high-throughput stream processingMessage broker designed for complex message routing
Message ModelPull-based: Consumers fetch messages from topicsPush-based: Brokers send messages to consumers
PersistenceMessages are retained based on retention policyMessages are deleted once consumed
OrderingMaintains order within a partitionEnsures FIFO unless priority queue is used
ScalabilityHorizontal scaling via partitionsScales with multiple brokers but can slow down under heavy load
Message RoutingUses topics and partitions to distribute messagesSupports complex routing with exchanges and queues

Message Handling Differences

FeatureKafkaRabbitMQ
Message ConsumptionConsumers track messages using an offset trackerBrokers ensure message delivery to consumers
Message PrioritizationNo message prioritySupports priority queues
Message DeletionMessages retained until retention period expiresMessages are deleted after consumption
ThroughputMillions of messages per secondThousands of messages per second (scales with more brokers)

Security and Protocol Support

FeatureKafkaRabbitMQ
SecurityUses TLS and JAAS authenticationProvides admin tools for user and broker security
Protocol SupportUses binary protocol over TCPSupports AMQP, MQTT, STOMP, and other legacy protocols
Programming LanguagesJava, Python, Node.jsJava, JavaScript, Go, C, Swift, PHP, .NET, and more

Use Cases

Use CaseKafkaRabbitMQ
Event Stream ReplayIdeal for log aggregation and data re-analysisNot suitable as messages are deleted after consumption
Real-time Data ProcessingHigh-throughput event streamingSupports real-time messaging but lower throughput
Complex Message RoutingLess flexible, topic-basedMore flexible with exchanges and queues
Guaranteed DeliveryConsumer-driven, does not guarantee immediate deliveryEnsures message delivery with push model
Backward CompatibilityBest for modern applicationsSupports older protocols and legacy applications

Scalability & Fault Tolerance

FeatureKafkaRabbitMQ
ScalabilityAdds partitions to distribute loadCan scale horizontally with multiple brokers
Fault ToleranceReplicates log files across multiple nodesSupports clustering with message replication

AWS Kinesis (Kafka alternative)

Collect, Process & Analyse Data Data Stream in Real Time on Large Scale

Component of Kinesis

1. Data Stream:

Capture, Process & Store Data Stream

  • Need to provisioned Data capacity ahead of time
  • Data Input from many sources eg IOT Device, Logs, Video.
  • Billing is per shard
  • Data is immutable: once inserted & cant be deleted once injected
  • Near real time ~200mS
  • Store data between 1Day -1year
  • Can reprocess/ replay data

Limitations

  • Need to mange scaling manually by splitting Shard or merging them back

Data Record: Consist of Key Value pair

  • Partition Key : help to direct data to specific shard and allow ordering of data.
  • Sequence no : Unique per/ partition Key in a Shard. Help location of data in shard
  • Data Blob of 1MB

Shard: Stream can be split into Shards.

Kinesis Workflow

Producer

Client/ Agent Producing Data as record in real time:

  • Input: 1MB/Sec/shard or 1000 Msg/Sec/shard
  • API:
    • PutRecord API to put data
    • PutRecords API to put data as batch to increase throughput & save cost
  • Supports
    • AWS SDK
    • Kinesis producer Library (KPL): C++, JAVA, batch, compression, retries
    • Kinesis Agent: built on top of KPL allow monitor logs
    • IOT
    • Application,App Clients

Hot partition: Chatty device can overload a shard partition

Cold partition: Shard partition with not enough data

ProvisionedThroughputException: When a shard receive data more than provisioned input capacity

  • Use Highly Distributed Partition Key to avoid hot partition.
  • Retry with Exponential back off
  • Shard Splitting -> increase capacity by increasing shard
    • Increase capacity by 1MB/Sec but also increase cost
    • Data in old shard will be expired and Old Shard wil be deleted.
    • 1 shard can spilt in Only 2 shard at a time

Shard Merging -> decrease capacity by decreasing shard

  • Decrease capacity by 1MB/Sec to reduce cost
  • Data in old shards will be expired and Old Shards wil be deleted.
  • Only 2 shard can merge in 1 at a time

Consumer

Consume Data from data stream

  • API:
    • GetRecords API to get data at 2MB/s/all consumer rate
    • SubscribeToShard: Enhanced FanOut Pattern 2MB/s/consumer rate
  • Output:
    • 2 MB/Sec/shard all consumer
    • 2 MB/Sec/shard per consumer
  • Support:
    • Apps
    • Lambda
      • Support Classic & Enhanced Data stream
      • Batching: can set batch Size & Window
      • Process 10 Batch/Shard
      • Support retries till data expire/succeed
    • Kinesis Data Hose
    • Kinesis Analytics,
    • Kinesis Client Library(KCL):

Consumer Pattern

1. Standard(Classic) Fan Out pattern

  • Read Throughput: 2MB/s/shard shared across all consumer
  • Use GetRecords API
  • Pull Model
  • Max 5 API Call/Sec = 2MBps*5 = 10MB/Sec (10K Record)
  • Latency ~200mS
  • Low Cost

2. Enhanced FanOut Pattern

  • 2MB/s/shard/consumer for all consumer
  • Use SubscribeToShard API to get update from shard
  • Push Model
  • Max 5 consumer/Data stream(default)
  • Latency: ~70mS
  • High Cost

Kinesis Client Library(KCL)

Java Library which help read data from Kinesis Data Stream

  • Runs on: EC2, Elastic Bean Stalk, on-premises
  • 1-1 Relationship: Each shard can be read by only one KCL instance
  • Checkpoints: Progress is check pointed into DynamoDB.
  • Share Workload: Use check points to Track the work among other workers and share the work among other Shard
  • Versions:
    • KCL 1.X Only Shared consumer
    • KCL 2.X Shared & Enhanced FanOut Consumer

KCL Auto load balancing Security:

  • KMS: Data at rest
  • HTTPS: data in transit
  • IAM: Access policy
  • VPC Endpoint: Access Kinesis within AWS network
  • Cloudtrail: Monitor APi calls

2. Data FireHose:

Read Data from Producers, Optional process them using Lambda & Batch write them into AWS target: S3, Elastic Search, Red Shift

Kinesis Firehose

  • Fully Manged service with automatic scaling
  • Source:
    • App, Clients
    • Kinesis Data Stream, Kineis Agent
    • Cloudwatch Logs, AWS IOT
  • Destination:
    • AWS target: S3, Elastic Search, Red Shift
    • custom HTTP end points
    • Third Party Destinations: MongoDB, Splunk, DataDog
  • Support many data format, conversion & transformations, compression
  • Optional Lambda can be used to transform data
  • Auto backup failed data to S3 Bucket
  • Min Batch Limit: 60 Sec or 32 MB : Near Real time

Limitations:

  • Does not support replay
Kinesis Data StreamKinesis Firehose
Ingest Data at ScaleIngest Data to S3, Redshift, ES, HTTP/ 3rd Party
Need to write own Producer/ConsumerFully Manged Service
Real Time (~200mS)Near Real Time (60 Sec or 32 MB)
Store Data between 1Day -1yearNo Data Store
Mange ScalingAuto Scaling
Pay per CapacityPay for Data goes through firehose
Replay CapacityCant replay Data

3. Data Analytics:

Real time analytics on stream of Kinetics Data Stream or Kinesis FireHose

  • Analyze Data using SQL or Apache Flunk
  • Run SQL Queries on Data STream in Real Time.
  • Fully managed, auto scaling
  • Pay for data pass
  • Source/ Destinations:
    • Kinetics Data Stream
    • Kinesis FireHose

4. Video Stream:

Capture process & store Video Stream

  • Usage: ML, Analytics on real time video stream
AWS/3.2-Streaming
Let's work together
+49 176-2019-2523
hiteshkrsahu@gmail.com
WhatsApp
Skype
Munich 🥨, Germany 🇩🇪, EU
Playstore
Hitesh Sahu's apps on Google Play Store
Need Help?
Let's Connect
Navigation
  Home/About
  Skills
  Work/Projects
  Lab/Experiments
  Contribution
  Awards
  Art/Sketches
  Thoughts
  Contact
Links
  Sitemap
  Legal Notice
  Privacy Policy

Made with

NextJS logo

NextJS by

hitesh Sahu

| © 2025 All rights reserved.