Amazon EventBridge, a serverless event bus service, makes it easy to connect your apps to data from multiple sources. EventBridge streams real-time data from your applications, Software-as-a-Service (SaaS) apps, and AWS services and directs it to destinations such as AWS Lambda. To create applications that respond quickly to all data sources, you can create routing rules.
Let’s start with an introduction to Amazon EventBridge: Learn how to build event-driven applications!
What is AWS EventBridge?
Amazon EventBridge is part of AWS Serverless ecosystem. It is a serverless event bus built on top of AWS CloudWatch Events API. AWS CloudWatch Events allows developers the ability to connect multiple AWS services via events. A CloudWatch Event can send AWS Lambda an event if an EC2 instance status changes.
EventBridge extends this capability outside of the AWS environment, allowing you to connect your own (old) applications, SaaS (Software-as-a-Service), and AWS Services. It can feed real time data from Symantec and PagerDuty, and route it to various destinations (AWS services like SQS, Lambda and others). EventBridge was launched with support for ten SaaS partners, more than 90 AWS service event sources, as well as 17 AWS service targets.
Image source – AWSWhat makes EventBridge different from other AWS services
Let’s take a look at AWS’ various event routing options and compare them to EventBridge. There are four main AWS-native options for event routing:
Let’s learn more about the differences between these.
CloudWatch Events vs EventBridge
CloudWatch Events is limited in its ability to support AWS services as event sources. It only uses the standard event bus to receive events from AWS services, PutEvents API calls, and other authorized accounts. You can modify permissions on the default events bus to authorize other users.
EventBridge lets you create custom event buses and SaaS events buses in addition to the default bus. The custom event bus can be used to manage custom events that are generated using the PutEvents APIs. The SaaS Event Bus is used to route events generated using SaaS services. EventBridge uses CloudWatch Events API to manage the default bus. CloudWatch Events customers can access their existing default bus rules and events through both the EventBridge interface or the CloudWatch Events console.
SNS vs EventBridge
SNS is a popular service for event-sourcing. It shines when the throughput is very high, reaching millions of TPS. EventBridge can handle only 400 queries per second. SNS supports a smaller number of targets than EventBridge. An example is that an event cannot activate Step Functions directly if the target is unavailable. It must invoke a Lambda function which can trigger the Step Functions. EventBridge now supports 17 targets. EventBridge Rules can only have 5 targets.
SNS is almost infinitely scalable. However, filtering is limited to characteristics and not event content. SNS does not guarantee the sequence of messages.
Kinesis vs EventBridge
Kinesis can be used for both event routing as well as event storage. This is a great option for large-scale, real-time data processing. Although it can be used to connect to multiple customers, there is a limit on how many customers can access a single stream. Each customer would be responsible to filter out communications they are not likely to be interested. Kinesis also offers order guarantee. However, it does not have a usage-based pricing model. It doesn’t scale automatically to meet demand. EventBridge, however, cannot buffer events. SQS and Kinesis connections are required for event storage.
AWS EventBridge Building blocks
Before we get into the inner workings EventBridge, let’s first look at the components of this service.
Events – A change that occurs in real time in a system or data is called an event. This can happen in your application, an AWS or SaaS partner service.
Event sources – An event supplier is used to ingest events from your app or a SaaS partner to an AWS customer account.
Event buses – In order to receive events from event sources you need an event bus created in your AWS account. There are many styles available for these event buses:
Default event bus — This default event bus receives events from all AWS services.
Event bus custom – This is a way to receive events from custom apps.
Partner event bus — This bus is for events that are sent to SaaS partner apps. It must be manually set up.
Rules — A rule is a set of rules that are connected to an event bus. From this bus, the events to match are scanned. If incoming events match the rule, they are forwarded to processing targets. You can also enable parallel processing by routing to multiple destinations. A rule can parse JSON, filter/customize it to deliver specific sections or rewrite content.
Targets – An event processor is a target. It supports JSON format for events. AWS services like Amazon EC2 instances and Lambda functions as well as Kinesis streams, Amazon ECS task, Amazon Step Functions, Amazon SNS subjects, and Amazon SQS could all be targets.
EventBridge: How it Works
Amazon EventBridge is a serverless event bus that supports publish/subscribe. SaaS apps send events to this event bus which then distributes them to one or several AWS target services.
First, create a rule. The rule must be in the exact same area as the target. A rule requires the existence of an event pattern. It is called mat