Decoupling AWS Infrastructure (Part 1)

Part 1, Part 2

Introduction

In this article, we will focus on the reason why we have to decouple our infrastructure. Also, we will talk about the strategies of loose coupling. And we will introduce Simple Queue Service (SQS) and Simple Notification Service (SNS) as well.

What is Decoupling?

We could explain decoupling with one sentence: design architectures with independent components. The more loosely our system is coupled, the more easily it scales, and the more fault-tolerant it can be.

Strategies to Loose Coupling

In fact, managed services and serverless architectures can provide greater reliability and efficiency in our environment. For best practice, we prefer to use serverless at time of need. Also, we may need a message queue to handle communication between applications. In addition, we should store the static assets on Amazon S3. When we want to do authentication or store user state, we prefer use AWS managed services.

In other words, we want to split features into individual components. Perhaps, some people will say it microservices. Therefore, we can benefit from a lower risk of change.

Amazon Simple Queue Service (SQS)

Simple Queue Service (SQS) is an AWS full managed message queueing service. It transmits any volume of messages at any level of throughput without losing messages or requiring other services to be always available. We always use it to easily and reliably communicate between components.

The queuing chain pattern enables asynchronous processing. There are some benefits of SQS. First of all, it is extremely scalable i.e. up to million of messages. Secondly, it is highly reliable because all messages are stored redundantly on multiple servers with several data centers. Thirdly, it is simple to use because message will only send in, then we pull out. In addition, it supports simultaneous read and write. Finally, it is secure due to the API credentials.

There are 3 main features of SQS:

  1. Visibility Timeout: it prevents multiple components from processing the same message.
  2. Dead Letter Queues: SQS will not process a dead letter queue. A dead letter queue can sideline and isolate the unsuccessfully processed messages.
  3. Sharing a Queue: SQS can share the queues with other AWS accounts and anonymously if they are given enough permission and policy. AWS will only charge the owner of the queue.

Amazon Simple Notification Service (SNS)

Amazon Simple Notification Service (SNS) enables us to setup, operate and send notifications to subscribing services. There are many types of subscriber: email, HTTP/HTTPS, SMS clients, SQS queues, mobile push messaging or even an AWS lambda function. However, it at most handles 256KB max per message.

Above table shows the difference between SNS and SQS.

Actually, we could build an architecture with mixture of SQS and SNS like above figure.

Conclusion

To conclude, we learnt what is decoupling and why we use it. Also, we know some strategies to decouple the architecture. Finally, AWS SQS and SNS can help us in decoupling.

Leave a Reply