Ouch! SQS Left A Hole In Your Pocket. So What's Next?
Tags: aws, serverless, beginners, cost
Published: 2022-04-23 08:49:14

Cloud computing has been around for two decades, and despite the data pointing to business efficiencies and cost-benefits, there are still a slew of ways for businesses to lose money and end up with a hole in their pockets. Not architecting applications correctly is one of those ways. 

This is the first part of a two-part article on identifying and addressing the functionality that contributes to the high cost of the AWS SQS service. The cost of SQS service is examined in this article, and the functionality that contributes the most to the overall cost is identified. The series' next post will go deeper into the root cause and provide potential solutions for dealing with it and, as a result, lowering SQS costs.

So you received your AWS bill and noticed that the SQS cost was greater than expected, but you don't have enough information to triage it. According to the bill, only the Requests-Tier1 usage type contributes to the SQS cost. We need more than that if we need to address cost. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jmz8h4p8eigdszbu6ex6.jpg)

The first step is to go to the AWS Cost Explorer and filter the costs by SQS service and API Operation. This graph shows the cost of various SQS API operations for the selected time frame. The Receive API operation is the one that contributes the most, as shown in the screenshot below. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2p4fq6oz1v54xj6pz1f.jpg)
Above information is sufficient if you have single application interacting with SQS. But what if you have multiple applications? You need a way to drill down further to identify which application associated with SQS is contributing the most to the cost.

At this point, I want to emphasis the significance of **_tagging_**. Because I have multiple applications interacting with SQS, tagging becomes **_REALLY REALLY_** important. Tagging allows you to organise your AWS resources in a variety of ways, such by purpose, application, owner, and environment. As a result, in my case, drilling down the SQS cost by application will be difficult without tagging.

During SQS creation, a custom tag called "ApplicationId" was added to it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m41006hoyl6xhlvv5lhs.png)
So, in the AWS Cost Explorer, the next step is to group the costs by the tag. This view categorises costs based on a custom tag. As shown in the screenshot below, the SQS connected with App01 (blue) is the one that contributes the most. We now know that App01 SQS should be our primary focus. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u76kf4ull8kzt31mrbfq.jpg)
The final step is to filter SQS service by tag and group the cost by API operations. This is to validate that the Read API operation that we identified in the previous step is still the operation that contributes the most to the APP01 SQS cost. And the answer is yes from the below screenshot. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/loy6hxlam0i5f5z0vkeh.jpg)
At this stage, we've determined that the Read SQS API operation is the one that has the most significant influence on SQS costs. So there's the "What". We do not, however, know "Why". The next question will be "How" to address it once we know the "Why". The "Why" and "How" questions will be addressed in the subsequent post in the series.

------------------------------------------------------------------

Thanks for reading!

If you enjoyed this article feel free to share on social media 🙂

Say Hello on: [Linkedin](https://www.linkedin.com/in/harinderseera/) | [Twitter](https://twitter.com/harinderseera) | [Polywork](https://www.polywork.com/harinderseera) 

Blogging: [Dev](https://dev.to/harinderseera) | [Hashnode](https://harinderseera.hashnode.dev/)