‫So let's first talk
‫about the first service
‫which would allow us to decouple our applications,
‫which is Amazon SQS,
‫which stands for Simple Queue Service.
‫So what's a queue?
‫Well, say we are creating an SQS queue, right here.
‫What we enable us to do is
‫to have producers send messages into that queue.
‫And then, it could be one producer,
‫but it could be as well multiple producers.
‫And then, once the messages are stored in a queue,
‫then they can be read by consumers
‫who will be polling the queue,
‫that means requesting messages from the queue,
‫they will be polling the queue,
‫and it could be one consumer,
‫but it could also be multiple consumers.
‫And in this example,
‫once the consumer polls messages,
‫they will share the work so each consumer
‫will get different messages,
‫and when they're done processing a message,
‫maybe for example, to process a video,
‫then they will delete the message
‫from the queue and it will be gone.
‫So in this mechanism,
‫we have the producer sending messages into the queue,
‫and they're decoupled from the consumer
‫reading the messages from the queue,
‫and processing them at different speed.
‫So when you have SQS,
‫turns out that it is the AWS oldest offering,
‫it's over ten years old,
‫it was one of the first services
‫to appear as part of the AWS cloud.
‫It is fully managed, so it's a serverless service,
‫you don't provision servers,
‫and it's used to decouple applications.
‫So this is the exam tip,
‫if you see "decouple", then think of SQS.
‫It will scale seamlessly, from example,
‫from one message a second,
‫to tens of thousands of messages per second.
‫And the default retention of the messages
‫is four days, maximum of 14 days.
‫So you need to process them
‫within that default retention.
‫There's no limit to how many messages can be in a queue.
‫And then, once the consumers read the messages,
‫then they have to be deleted, so they're gone.
‫There is low latency, we're talking about less
‫than ten milliseconds on publish and subscribe.
‫And then, consumers share the work
‫to read messages and scale horizontally.
‫So SQS can be used to decouple
‫between your application tiers.
‫So here's a classic solution architecture.
‫We have our web servers,
‫and they're taking request, maybe,
‫through an application load balancer.
‫They are served through EC2 instances
‫in an auto scaling group,
‫and then, for example,
‫say that our users want us to process some videos.
‫Then instead of sending it directly
‫to the video application,
‫we can instead insert messages into an SQS queue.
‫And then, we will have a video processing layer
‫made of an auto scaling group with EC2 instances,
‫and these EC2 instances will be reading
‫from the SQS queue and processing our videos.
‫The cool thing about it
‫is that we can scale the second auto scaling group
‫independently from the first one.
‫And this is why it's called decoupling,
‫and on top of it,
‫the scaling can happens based on how many messages,
‫for example, there are in the SQS queue.
‫And this would really allow us to have two layers,
‫the web servers and the video processing,
‫fully decoupled from the SQS queue,
‫and scaling independently.
‫This will give us the best user experience,
‫and also the best cost efficiency
‫and scaling concerns.
‫So I hope you liked this,
‫I will see you in the next lecture.