Serverless Tip #5: When to use SQS, SNS, or EventBridge?
As Werner Vogels said, the world is asynchronous. Asynchronous, or event-driven, systems are the bread and butter of serverless. AWS provides a few different services to build a decoupled event-driven system. But when should you use which?
Use 𝐄𝐯𝐞𝐧𝐭𝐁𝐫𝐢𝐝𝐠𝐞 to publish and route messages to many consumers based on flexible event patterns. You can transform events on the fly, and EventBridge Pipes can act as the glue between different services.
Use 𝐒𝐐𝐒 for 1:1 asynchronous communication with buffering. If your upstream systems scale more than downstream systems, queues can help you buffer and control the rate at which messages flow between them.
Use 𝐒𝐍𝐒 when you want to fan out messages with high throughput to a large number of consumers. Millions of consumers can subscribe to a single topic.