Devlane Blog
>
Mobile & Web

Amazon SQS & SNS, What are those?

Amazon Web Services (AWS) is a suite of cloud computing services that runs on the same infrastructure that Amazon uses for its e-commerce website. AWS offers various services, including computing, storage, networking, databases, analytics, machine learning, artificial intelligence, Internet of Things (IoT), mobile, security, hybrid, virtual and augmented reality (VR and AR), media, and customer engagement tools.

by
Marny Lopez
|
February 29, 2024

AWS is a popular choice for businesses of all sizes, from startups to enterprises. It offers a pay-as-you-go pricing model, which makes it easy to scale your resources up or down as needed.

AWS is also highly scalable, so you can easily add or remove resources as your needs change.

What is Amazon SQS?

Amazon Simple Queue Service (SQS) is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications.

SQS offers two types of queues: standard queues and FIFO queues. Standard queues are ideal for a variety of applications, including:

  • Asynchronous processing: SQS can be used to decouple components of an application so that they can process messages independently. This can help to improve performance and scalability.
  • Load balancing: SQS can be used to distribute messages across multiple consumers, which can help to balance the load on your application.
  • Reliability: SQS offers durable message storage, so you can be confident that your messages will not be lost.

FIFO queues are ideal for applications that require strict message ordering. For example, you could use a FIFO queue to ensure that orders are processed in the order in which they were received.

What is Amazon SNS?

Amazon Simple Notification Service (SNS) is a fully managed pub/sub messaging service that enables you to decouple microservices, distributed systems, and serverless applications.

SNS offers two types of topics: standard topics and FIFO topics. Standard topics are ideal for a variety of applications, including:

  • Sending notifications: SNS can send notifications to subscribers, such as email, SMS, or HTTP endpoints. This can be used to notify users of events, such as the completion of a job or the arrival of a new message.
  • Event-driven programming: SNS can trigger events based on messages, such as starting a new process or updating a database. This can automate your applications and make them more responsive.

FIFO topics are ideal for applications that require strict message ordering. For example, you could use a FIFO topic to ensure that notifications are sent in the order they were received.

Differences between SQS and SNS

SQS and SNS are both messaging services, but they have different strengths and weaknesses. SQS is better suited for applications that require decoupling and scalability, while SNS is better suited for applications that require message ordering and event-driven programming.

Here is a table that summarizes the key differences between SQS and SNS:

When to use SQS and SNS

If you are unsure whether to use SQS or SNS, here are a few things to consider:

  • Do you need decoupling and scalability? If yes, then SQS is a good choice.
  • Do you need message ordering? If yes, then SNS is a good choice.
  • Do you need event-driven programming? If yes, then SNS is a good choice.

If you are still unsure, then try using both SQS and SNS and see which one works better for your application.

An example of an app that uses SQS

A web application that allows users to upload images. The application could use SQS to decouple the image upload process from the image processing process. The image upload process would put the image file into an SQS queue. The image processing process would then poll the queue for new images and process them one at a time. This would allow the image upload process to continue uploading images even if the image processing process is temporarily unavailable.

An example of an app that uses SNS

A mobile app that allows users to subscribe to news updates. The app could use SNS to send notifications to users when new news articles are published. The app would publish a message to an SNS topic whenever a recent news article is published. Subscribers to the topic would then receive notifications on their mobile devices. This would allow users to stay up-to-date on the latest news without constantly checking the app.

SQS and SNS are two robust messaging services that can decouple, scale, and automate your applications. They offer a variety of features and capabilities that can be used to solve a wide range of problems.

When choosing between SQS and SNS, it is essential to consider the specific needs of your application. If you need decoupling and scalability, then SQS is a good choice. If you need message ordering and event-driven programming, then SNS is a good choice.

In addition to the examples mentioned in the blog post, here are some other examples of applications that could use SQS and SNS:

  • A microservices architecture: SQS can be used to decouple microservices and ensure that they communicate with each other in a reliable and scalable way.
  • A batch processing system: SQS can be used to queue up tasks for processing in a batch, which can help to improve performance and efficiency.
  • A real-time streaming application: SNS can be used to send notifications to subscribers as soon as new data is available, which can help to improve the responsiveness of your application.

SQS and SNS are both fully managed services, which means that AWS takes care of all of the underlying infrastructure. This makes it easy to get started with these services and to scale them as your application grows.

If you want a powerful messaging service to decouple, scale and automate your applications, then SQS and SNS are great options.