AWS
DevOps
  • knowledge
    • glossary
    • network knowledge
      • CIDR Block
      • OSI
      • List of Ports
      • Network model
    • AWS best practices
      • Least privilege principle
      • Support Plan
      • Well-architected framework
        • Well-architected framework
        • Cost optimization
        • Operational Excellence
        • Performance efficiency
        • Reliability
        • Security
    • Exams
      • DOP-C02
        • DOP-C02 topics
        • DOP-C02 Labs
      • DVA-C02
      • SOA-C02
  • services
    • access management
      • Directory Service
      • IAM
        • PassRole
      • IAM Identity Center (SSO)
      • Organizations
        • Organizational Unit
        • Control Tower
      • AD Domain Service
    • analytics
      • data analytic
        • Athena
        • QuickSight
        • Redshift
      • data collection
        • Data Lake
        • Lake Formation
      • data processing
        • EMR
        • Kinesis
        • Glue
          • Glue Data Catalog
      • OpenSearch
    • compute
      • Batch
      • EC2
        • Auto Scaling
        • AMI
        • ELB
          • Global accelerator
        • Security Group
        • EBS
        • EC2 Instance Store
        • Spot Fleet
      • Elastic Beanstalk
      • Lambda
        • Layer
        • Lambda API
      • Outposts
      • Wavelength
      • SAM
      • VMWare Cloud
    • container
      • Copilot
      • ECR
      • ECS
        • ECS Anywhere
      • EKS
        • EKS Anywhere
        • EKS Distro
      • Fargate
    • cost management
      • Budgets
      • Cost Explorer
      • Saving Plans
      • Compute Optimizer
    • database
      • Data Engineer
      • Document DB
      • DynamoDB
        • DynamoDB API
        • Scan
      • ElastiCache
      • Keyspaces
      • MemoryDB for Redis
      • Neptune
      • Quantum Ledger Database
      • RDS
        • Aurora
          • Aurora Global Database
          • Aurora Serverless
      • Timestream
    • devTools
      • CICD
        • CodeArtifact
        • CodeCommit
        • CodeBuild
        • CodeDeploy
        • CodePipeline
      • CloudFormation
      • CodeGuru
      • CodeStar
      • CodeWhisperer
      • X-Ray
      • Deployment strategies
    • finance
      • Cost explorer
    • integration
      • AppFlow
      • AppSync
      • EventBridge
      • MQ
      • SNS
      • SQS
      • Step Functions
      • SWF
    • management
      • AppConfig
      • AWS Backup
      • AWS CDK
      • Config
      • Grafana
      • Health Dashboard
      • Proton
      • Service Catalog
      • System Manager
      • SSM
      • Resource Group
      • OpsWorks (discontinued)
    • media
      • Elemental MediaConvert
      • Transcoder
    • messaging
      • SES
    • migration
      • Application Migration Service
      • DataSync
      • DMS
      • Migration Evaluator
      • Migration Hub
      • Server Migration Service
      • Snow Family
      • Transfer Family
    • ML
      • Comprehend
      • Forecast
      • Kendra
      • Lex
      • Rekognition
      • SageMaker
        • SageMaker Data Wrangler
        • SageMaker ML Lineage Tracking
    • monitoring
      • CloudTrail
      • CloudWatch
      • TrustedAdvisor
    • networking
      • CloudFront
      • Customer gateway
      • Edge Location
      • hybrid networking
        • Direct Connect
          • Direct Connect Gateway
        • Site-to-site VPN
      • PrivateLink
      • Region
        • AZ
      • Route 53
      • Transit Gateway
      • VPC
        • VPC Lattice
        • Subnet
          • NACL
        • Internet Gateway
        • Network Firewall
        • VPN
        • NAT Gateway
      • Virtual Private Gateway
    • security
      • Artifact
      • ACM
      • CloudHSM
      • Cognito
      • Detective
      • Firewall Manager
      • GuardDuty
      • Inspector
      • KMS
      • Macie
      • Network Firewall
      • Resource Access Manager
      • Security Hub
      • Secret Manager
      • Secret Hub
      • Shield
      • STS
      • Trusted Advisor
      • WAF
    • storage
      • Backup
      • EBS
      • EFS
      • FSx
      • S3
        • S3 Glacier
        • S3 Snippet
        • S3 Mountpoint
      • Snow family
      • Storage gateway
      • WorkDocs
    • web & mobile
      • Amplify
      • API Gateway
      • Device Farm
      • Pinpoint
Powered by GitBook
On this page
  • Overview
  • Concepts
  • Benefits
  • Features
  • Queue types
  • Use cases
  • Buffer to database writes
  • Decouple between application tiers
  • Integrate 2 Lambda functions (producer & consumer)
  • Security
  • Encryption
  • SQS Access Policies
  • Best practices
  • Trivia
  1. services
  2. integration

SQS

fully managed message queuing service

PreviousSNSNextStep Functions

Last updated 1 year ago

| | |

Overview

  • fully managed message queuing service

  • provide way for asynchronously communicate between applications, without loosing messages

    • How? It stores the copies of messages redundantly across multi-AZ.

  • decouple and scale microservices, distributed system and serverless applications.

Concepts

    • default polling setting.

    • WaitTimeSeconds = 0. Messages are returned immediately.

  • ReceiveMessageWaitTimeSeconds: when the wait time of ReceiveMessage API > 0, long polling are in effect. Long polling help reduce empty responses.

      • WaitTimeSeconds > 0

      • Maximum wait time: 20 secs

  • VisibilityTimeout: after a message is received, it still remains in the queue. The length of time which a message unavailable after delivering. To stop other consumers from processing that message again -> set visibility timeout on the ReceiveMessage API call to beyond what the longest transaction takes to process.

    • Default: 30 seconds. Min is 0 sec, Max is 12 hours.

    • Increase VisibilityTimeout if a consumer received message more than one.

aws sqs set-queue-attributes --queue-url <queue-url> --attributes VisibilityTimeout=120
  • MessageRetentionPeriod: seconds that SQS will keep the message. Default is 4 days.

  • DelaySeconds: seconds for which the delivery of all messages is delayed. Default is 0 second.

Benefits

  • Eliminate administrative overhead.

  • Reliability delivery messages

  • Scale elastically and cost-effectively.

Features

  • Redundantly stores messages across multiple servers.

  • Automatically scale

  • Built-in encryption, access control features

  • Message locking: when a message received, it is locked for processing.

    • When completed, it deletes the message from the queue.

    • When failed, the lock expire -> the message is available again.

  • Queue sharing: queue can be shared anonymously or to specific AWS accounts.

Queue types

-
Standard
FIFO

Throughput

unlimited

3000 msg/sec

Delivery type

Best-effort ordering (out of order)

FIFO

Duplicate?

Yes

No (exactly-once send) built-in deduplication and ordering capabilities.

Ordering

No

Yes

Use cases

Buffer to database writes

Decouple between application tiers

Integrate 2 Lambda functions (producer & consumer)

Security

Encryption

  • In-flight encryption: HTTPS API

  • At rest encryption: KMS keys

  • Client-side encryption

  • Server-side encryption (SSE): encrypt each message body

SQS Access Policies

  • Similar to S3 bucket policies

  • Useful for cross-account access to SQS queues.

Best practices

  • Use batching: sending messages in batch can improve performance and reduce costs.

  • Setting appropriate visibility timeouts

  • Monitor your queues.

Trivia

  • Cannot change the queue type (Standard -> FIFO or FIFO -> Standard) after you create the queue.

  • Message is persisted in SQS until a consumer deletes it.

  • Message retention: default 4 days, up to 14 days.

  • When need a solution with decoup or performance improvement by distribute load, use SQS.

(DLQ): contains messages that could not be processed.

:

:

Keep sensitive data secure. Refer .

Dead-letter queue
Short polling
Long polling
encryption
AWS Document
Workshop
FAQs
SQS queue
integrating serverless application