This is the third in a three-part series covering the Amazon Web Services (AWS) free tier. In our previous articles, we reviewed the free tier for the AWS compute and database offerings. In this article, you will learn about the messaging options provided by AWS. We will cover Amazon Simple Queue Service (SQS), Amazon Simple Notification Service (SNS), and Amazon Simple Email Service (SES).
For each tool, we will cover what it is, how it’s billed and the available free tier, and some example projects you can try.
Table of Contents
Amazon Simple Queue Service (SQS): What it is
Amazon SQS is a fully-managed queue service provided by AWS. Queues are a useful addition to your application architecture with many use cases. They can be used to throttle load in a crucial area of your system, reliably process batches of work, or communicate between microservices. There are a number of message queues in popular use today, including RabbitMQ, ActiveMQ, or RocketMQ.
SQS was one of the first products released by AWS. It was initially released in 2004, then re-released in 2006 as part of a broader AWS relaunch. While many other message queues use custom protocols such as AMQP, STOMP, or MQTT, AWS decided to use HTTP as the protocol for interacting with SQS. All messages are sent to SQS over HTTP, and a consumer can receive messages from SQS via HTTP.
While SQS started out with simple queue semantics, it has continued to add features since its release. Some of the most notable advanced features are:
- First-in, first-out (FIFO) queues: By default, SQS provides no guarantees about the order in which your messages will be processed. You can pay an additional fee to use FIFO queues, which guarantee that messages will be processed in the order they were received. This can be useful for non-idempotent tasks where subsequent messages depend on the results from prior messages.
- Dead-letter queues (DLQ): Occasionally you may have a message that cannot be processed by your workers, whether during to improper formatting or because of other limitations in your systems. SQS allows you to set up a dead-letter queue, where it sends messages that has been unsuccessfully processed a given number of times. This can help you avoid poisoning your queue with messages that are invalid.
- Long-polling: As mentioned, SQS uses HTTP rather than a stateful connection to the message broker. When your queue is empty, you will need to continually ping your queue to see if any new messages have arrived. With long-polling, you can make a request to receive messages and wait up to 20 seconds to see if any messages arrive.
SQS is one of AWS’s powerhouse services due to its simple, fully-managed nature in providing a key component of application architectures. In the next section, we’ll learn about how SQS is priced and what is available from the AWS Free Tier.
SQS is primarily priced on one factor: the number of requests you make. Each API request you make is treated equally -- sending a message to SQS is priced the same as requesting to receive a message or listing all the queues in your AWS account.
The price per request depends on whether you use a standard queue or a FIFO queue. These prices are:
- Standard queue: $0.40 per million requests, or $0.00000040 per request)
- FIFO queue: $0.50 per million requests, or $0.00000050 per request)
The price-per-request nature of SQS is a huge selling point. Rather than maintaining your own always-running RabbitMQ instances on EC2, you can get the exact throughput and scale you need with SQS. Further, since you only pay per request and not per queue, it is costless to add additional queues into your infrastructure. This allows you to set up your queueing architecture on a granular basis that fits your application needs.
Like many AWS services, SQS also has data transfer costs. For data transfer IN to SQS, you are not charged. For the first GB of data OUT of SQS, you are also not charged. For additional data transfer OUT of SQS, prices vary by region. Prices are between $0.09 per GB and $0.25 per GB and decrease as your data transfer throughput increases.
SQS has a free tier of 1 million SQS requests per month. This is in the forever free tier, so it doesn’t expire 12 months after you sign up with your AWS account. Due to the low price of SQS, this only saves you $0.40 - $0.50 per month. However, many applications can run entirely within the free tier on SQS until they start to scale up.
In the next section, we will look at a few projects you can try with the SQS free tier.
Example Projects with SQS Free Tier
Amazon SQS is a flexible queuing system and can be used for a wide variety of projects. It is often used to offload long-running tasks in web applications or to communicate between microservices. Below are a few guides to get you started.
- Managing Amazon SQS Queues in Java
- Using SQS with AWS Lambda and Serverless
- Using Python and Amazon SQS FIFO Queues to Preserve Message Sequencing
Amazon Simple Notification Service (SNS): What it is
Amazon SNS is a fully-managed pub/sub messaging system. It was released in 2010, which makes it one of the older AWS services. It provides an easy, stable technology for common pub/sub needs.
There are two main uses for SNS. First, you can use it as a traditional pub/sub messaging system. An example here is a microservice architecture where Service A may be interested in updates to objects in Service B. Rather than Service B directly notifying Service A about the update, Service B can send a message to an SNS Topic with details about the update. Service A can subscribe to the topic and process the messages as they arrive. The main alternatives to using SNS in this manner are tools like RabbitMQ in pub/sub mode or NATS.
The second core use case for SNS is to deliver messages to large numbers of end users, such as via mobile push notifications or SMS messages. SNS allows for extremely high fan-out in these use cases, as you can have up to 12.5 million subscribers to a single topic. This is great for blasting your users with updates about a new sale or news in your application.
In the next section, we’ll cover how SNS is priced and what the Free Tier provides.
Amazon SNS: Billing and Free Tier
SNS is primarily billed across two axes; publishes and deliveries.
A publish is when you send a message to an SNS topic. Publishes are charged at $0.50 per million. Note that while SNS has a maximum message size of 256KB, each 64KB of data in a publish counts as a separate request. Thus, if you send a message that’s 128KB, that will be billed as two requests.
SNS also charges based on deliveries. As noted above, you may have up to 12.5 million subscriptions to a single topic. Each delivery will be charged to you. The price for delivery depends on the endpoint type.
The price for the endpoint types are:
- Mobile push notifications: $0.50 per million deliveries;
- Email: $2.00 per 100,000;
- HTTP/s (e.g. webhooks): $0.60 per million;
- Simple Queue Service (SQS): No charge
- Lambda functions: No charge.
- Worldwide SMS: Special pricing
As you can see, you can subscribe SQS queues or Lambda functions to SNS topics for processing. You are not charged for delivery to those services, but you will pay the regular charges for the usage of those services.
SNS has a nice free tier to get you going with pub/sub messaging. This free tier does not expire, so you can continue to use it even after the first year of your AWS account. The free tier includes:
- 1 million SNS publishes per month ($0.50 value)
- 1 million mobile push notification deliveries per month ($0.50 value)
- 1,000 email deliveries per month ($0.20 value)
- 100,000 HTTP/s deliveries per month ($0.06 value)
Like SQS and many other AWS services, you will also pay data transfer costs with SNS. The charges are similar to SQS -- no charge for data transfer IN, and no charge for the first GB per month of data transfer OUT. Additional data transfer OUT is priced on a per-GB basis that varies across regions.
With this pricing and free tier in mind, let’s see how we can try SNS.
Example Projects with the SNS Free Tier
SNS is great for both traditional pub/sub and for high fan-out to end users. Below are a few examples for each of the two use cases:
- Sending SMS Messages with Amazon SNS
- Using Amazon SNS for System-to-System Messaging with an HTTP/S Endpoint as a Subscriber
- Amazon SNS (Simple Notification Service) Using C# and Visual Studio
- Triggering Lambda with SNS Messaging
Amazon Simple Email Service (SES): What it is
Amazon SES is a fully-managed email service provided by AWS. It allows for both sending and receiving email.
The core main use case for SES is sending email. There are two email types. First is transactional email. Transaction email is when you send an automated message to a specific person. For example, you could send a customer an email that their order has shipped, or you can alert a user about the subscription ending.
The second bucket of outgoing email is marketing email. This is when you send the same email to a large number of users at the same time. This could be notifying your email list of a large upcoming sale or making an announcement of a new product.
When sending large amounts of email, you need to focus heavily on deliverability. Spam is a major problem with email, so you need to be sure you are not spamming your users or sending unwanted email. If your domain is marked as spam, many of your communications will end up in your users’ junk mail folders.
Many of the email service providers, such as Mailchimp or Sendgrid, work hard to protect your domains and assist you in avoiding spam filters. With SES, you are more on your own in avoiding that. AWS does provide some tips on email deliverability, but you need to remain vigilant.
In addition to sending email, you can also use SES to receive emails. Given the popularity and feature set of free email inbox providers like Gmail, Hotmail, and others, SES is not likely to be the main interface for your email inbox. However, you can use it for automating responses or handling inbound ticket requests.
Now that we know about SES key use cases, let’s dig in to the billing and free tier.
Amazon SES: Billing and Free Tier
SES is billed along two main axes:
- Sending email: $0.10 per 1,000 messages, plus $0.12 per GB for attachments;
- Receiving email: $0.10 per 1,000 messages, plus $0.09 per 1,000 “chunks” of 256KB.
Additionally, you can get a dedicated IP address from which to send your email. Having a dedicated IP address can help with the deliverability concerns mentioned in the previous section. A dedicated IP address is priced at $24.95 per month.
The free tier for SES is not particularly generous. You can receive up to 1,000 emails for free under the free tier. Additionally, you can send up to 62,000 emails for free each month, if the emails are sent from an application running in EC2. While this is a nice perk, you will need to pay the normal EC2 prices for your application. Finally, you are still responsible for the additional charges based on size of attachments or size of incoming mail under the free tier.
With this pricing in mind, let’s look at some example projects with SES.
Example Projects with the SES Free Tier
As mentioned, SES is best when used for sending email. There are two core types of business email sending -- transactional email and marketing email.
Below are guides for each of the two types:
- Using SES to Send Transactional Email for Free
- How to Send Email Marketing Campaigns with SES (Video)
- Set up Amazon SES for your WordPress Site
In this article, we reviewed the core messaging offerings provided by AWS. SQS and SNS in particular are core elements of many AWS architectures. They provide rock-solid reliability and simplicity in pay-per-use pricing. For each of the messaging services we reviewed, we examined the core use cases, the pricing model, and some example projects.