by • April 3, 2023
In day-to-day life, everything is driven by events. If the phone rings, you pick it up. If the timer on the oven pings, you switch it off. These are all examples of event-driven reactions, where the action is based on the conditions surrounding it. How does this relate to business IT systems? To begin to understand this, it helps to think of your company as a collection of events. Some of these events occur over and over, such as customer purchases or CRM data entry. Every time an event occurs, it impacts some other area in the business. For example, a customer purchase will prompt logistics to start the shipping journey and trigger a confirmation email or SMS. Event-driven architecture, or EDA, creates systems built on this culture, relying on communication via messages that contain accurate information to prompt the system so it performs essential tasks in the right sequence.
Generate a full-featured, documented, and secure REST API in minutes.
Event-driven architecture is a systems design approach that involves recording events and using asynchronous messages to communicate with system components. The event may also be called a message. For that reason, you may also see this type of systems architecture called “message-driven architecture.” Events or messages contain data pertinent to the task it needs the service to do.
Crucially, events are immutable. This means that their states can’t be modified in any way once they’ve been created. Immutable events carry data to relevant services to prompt actions. They never get the messages wrong because they cannot be changed, deleted, or impacted by other variables.
There are many ways to create EDA-based systems or applications. AWS offers Amazon EventBridge, a serverless event bus that connects apps using data from a variety of sources. Apache Kafka is another solution for creating systems with an event-driven architecture. Open source options, like the self-managed version of OpenShift, are also available.
An event-driven system usually has three main components:
Event producers are the creators of events or messages. The broker, or event router, ensures the event messages are distributed to the correct event consumers. Consumers are the endpoints of the chain, reacting to event data and executing relevant tasks. This is also sometimes called a publish/subscribe (pub/sub) model.
An online shopper is ready to buy a product from an e-commerce site. When they click “buy now,” this triggers an event. The event will contain data including, but not limited to:
The event goes to multiple services. One of these services may trigger an adjustment to customer recommendations. This does not require a response of any kind. The event simply provides the necessary data.
However, some events do require a response. When the customer pays online, the relevant event will communicate with some sort of payment service. This service will either confirm the payment has been made or show that the payment was declined. Either way, the system needs a response, and fast, so it can let the customer in the e-shop know whether the order has been successful. This response, which is another event, may trigger further events, such as messages to logistics services.
EDA architectural patterns determine how the producers, brokers, and consumers actually communicate. We’ve looked at the publisher/subscriber pattern in some detail, but there is also a commonly used EDA pattern called event streaming.
Rather than single events calling between producers and consumers, event streaming creates a log of events that all consumers can access. Event stream processing is ideal for systems where a history of events and changed states is essential and can allow for more complex event processing.
In most traditional data architecture-based systems, each service needs to have and maintain a direct line of communication to send calls. In EDA, all that’s required is the event and the underlying business logic that tells services what to do with the data within the event.
If Service A needs to contact Service B, in a traditional setup, Service A constantly needs to be aware of Service B’s existence for this to happen. With EDA, Service A simply generates an event and Service B just needs to know about this event. This is called an inverted dependency because the onus moves from Service A to Service B. This is also a great example of decoupling. The services don’t need to maintain any kind of permanent connection. They will communicate via events, and only when conditions prompt those events to be generated.
Because events are immutable, they can also interact with other services within the system. This is ideal when a single event should cause multiple tasks to execute. Going back to our earlier example of the customer purchase, you might want to ensure the customer gets an order confirmation message, plus the warehouse needs to know to start packing an order. Databases need to adjust the stock information, and the CRM may need updating with the purchase information. Based on event-driven architecture, a single event could prompt all those actions within a system.
Events can also be persistent. This means they will continue to provide the data for as long as it’s required by the service or services (also called subscribers). This helps if the receiving service or consumer service is down, as the call will continue periodically until the consumer service acknowledges receipt of the event.
Switching from legacy systems to EDA only makes sense if it can improve how you do business or make app development easier. Companies like Amazon utilize EDA in their AWS suite of services partly because of the following benefits.
Combined with microservices, EDA promotes agility via persistence and logs that allow a rollback to previous states if errors occur and debugging is required. For DevOps teams, this makes deployment faster and ensures they deliver a more reliable, stable product.
Because events are persistent and remove the risk of a single point of failure when a service goes down or becomes unresponsive, it promotes a far more flexible system prone to less downtime.
Because a single event can trigger multiple actions, EDA can be infinitely scalable. The loose coupling or decoupling of systems allows developers to adjust their tech stack with ease, adding further tools and data sources as needed.
For many businesses, data comes from a wide range of apps and devices, including sensors and wearables via the Internet of Things (IoT). These data points are increasing all the time. In fact, Statista predicts that by 2025, the average person will interact with 5,000 digital engagement points every day. As the IoT expands and consumers engage with organizations via more varied methods, companies need to ensure their systems can cope with these disparate data sources. Event-driven applications are ideally suited to deal with this increasing volume and variety of data.
Adding a broker or intermediary into the system to relay messages between services could use more resources and potentially lower the performance of a system.
There’s also the potential for delays, especially in cases where events aren’t delivered promptly, or where a single event has to communicate with a multitude of systems. Multiple subscribers can end up receiving event messages at different times, which can leave a system out of sync.
EDA-based systems are also more complex to build. Observability can be more difficult to handle, as there are so many communication channels active and it’s not always clear exactly when messages are being sent and received, although event streams help with this.
If you prioritize scalability over performance, EDA is most likely the right system architecture for your organization. EDA also supports data replication, allowing the same information to automatically go to multiple components within the system. This can help unify information available across your company and prevent data silos. EDA is also ideal for parallel processing, where multiple services need to execute tasks in tandem.
There are many reasons businesses might choose to switch to an EDA-based system.
For developers, EDA promotes the ability to deliver powerful experiences in real-time. Currently, there’s still a trade-off between scalability and performance. As technology advances, we could see that change. Systems developers will benefit from working with partners that empower them to manage the automation of instant API creation for seamless connections between disparate systems and data sources. Once EDA exists with virtually zero latency and affordable, multiple redundancies, developers could gain the freedom to expand their capabilities far beyond their current options.
Start your free trial and discover how DreamFactory supports comprehensive API management across any runtime environment, via a low-code platform that helps you effortlessly connect to your enterprise data and systems.
Multi-Tenant vs. Single-Tenant Systems: Which Is the Optimal Choice?
As a seasoned content moderator with a keen eye for detail and a passion for upholding the highest standards of quality and integrity in all of their work, Spencer Nguyen brings a professional yet empathetic approach to every task.
Join the DreamFactory newsletter list.