Benefits of Event-Driven Architectures to Complement Your REST APIs

PinIt

An event-driven architecture provides a number of advantages over REST APIs for modern applications deployed across hybrid cloud environments.

Event-driven architectures (EDA) provide a number of benefits to complement  REST API-based service-oriented architectures (SOA). This article will provide definitions and cover a number of differences and benefits when using it instead of a pure synchronous approach.

First, let’s define the terminology:

  • Event-driven architecture (EDA) is a software architecture paradigm promoting the production, detection, consumption of, and reaction to events, where an event can be defined as “a significant change in state.”
  • Service-oriented architecture (SOA) defines services that provide a discrete set of functionality to clients over a network, typically using  a synchronous request-reply interaction.   
  • REST (Representational  State Transfer) is a more constrained implementation of SOA. It  uses HTTP verbs and URIs to access resources, implements a client-server interaction, and is stateless. 
  • Web service APIs that follow the REST constraints are called RESTful APIs, or REST APIs for short.

An EDA uses events to communicate between decoupled producers and consumers. REST APIs implement a synchronous request-reply interaction between client and server (i.e., they are service-oriented).  A synchronous event publishing REST APIs exposed by a broker can be used to produce events, but direct event production and consumption by participating applications is simpler.  

EDA enables more parallel processing 

Events are naturally asynchronous, so producers broadcast events and continue processing other requests. One or more consumers process the events of interest to them. That’s In contrast to the REST APIs, where the client calls the servers sequentially, in a synchronous request-reply interaction pattern, and waits for the response from each, before calling the next API. The event producer does not have to wait for consumers.

Interconnecting multiclouds simplifies distributed processing of events, especially when using advanced middleware like VANs (Virtual Application Networks) versus generally location-aware REST API-based services. This increases the opportunity for parallel processing of events across clusters.

EDA allows designers to build more fault-tolerant applications 

With the asynchronous decoupling between event producers and consumers, the event consumers may be offline or recovering, while the producers keep producing events. Again, that’s in contrast to REST APIs, where both server and client need to be up at all times. Event processing systems also buffer and store events during slow-downs or failures of consumers. REST APIs require server capacity to handle peaks or API gateways to throttle client requests and avoid overloading servers, smoothing out bursts of events so that consumers are never overwhelmed.

An EDA is thus inherently more fault-tolerant, without any further infrastructure or complications.

EDA facilitates real-time responsiveness

Event consumers listen for the events that propagate quickly through the enterprise, enabling widely distributed consumers to take action in near-real-time. REST APIs can be used to poll for changes by calling on a frequent interval looking for recent updates. However, polling introduces delays and unnecessary checking when there are no changes.

Many consumers can see an event at the same time, so that multiple actions can be triggered, in contrast to REST APIs, where typically a single service is invoked at a time. 

Also, REST APIs do not offer a time-window sequence of historical calls. However, with event streams, especially when persisting the events, this history is readily available. Analytics leveraging new or existing event streams can make real-time decisions based on a time window of events. Event streaming middleware usually offers several operators, including sliding-window aggregations, which directly aid in implementing analytics.

While an event stream is an immutable sequence of events, ordered by the time of creation,  event streams can be transformed and aggregated into other event streams. Streaming analytics is processing one or more event streams, to identify other events or some type of actionable information, based on the patterns and correlations of the events and perhaps other entities. Modern analytics usually involves AI or machine learning algorithms for purposes such as making predictions about a user’s or system’s future behavior. For example, applications might include analysis of shopping or browsing patterns or failure predictions in a system.

EDA improves observability and extensibility 

EDA applications produce events for all entity state changes, which can be persisted by the messaging layer to facilitate better observability. That is in contrast to the REST request/response messages, which would need to be explicitly persisted by integration brokers or by the client or server. The reason for this is that the REST protocol does not have an inherent persistence mechanism. Persisted event streams facilitate anomaly and pattern detection, service-level monitoring, and IT ops.

Simulating scenarios from past events, as well as looking back in time and reconstructing a sequence of events or performing root cause analysis, are much easier when all relevant events are persisted for a longer period of time.

EDA’s loose coupling supports the addition of consumers or producers without affecting existing components allowing for a more flexible architecture. Such an architecture can better respond to changing business needs. In REST systems, because of the tight coupling between components, adding functionality requires potentially breaking changes to the components.

EDA facilitates deployment across the hybrid cloud

EDA components can be deployed across clouds and on-premises without the need for additional infrastructure like API gateways, load balancers, or other systems required for REST APIs.

The decoupling between components in EDA encourages interconnecting clouds, by easily moving, replicating, or partitioning consumers and producers. VANs (virtual application networks) can be used to interconnect clusters and multiclouds and offer many features for routing communications in the cloud, for both redundancy and resilience but also cost-based efficient routing.

Additionally, iterconnecting multiclouds simplifies distributed processing of events, especially when using advanced middleware like VANs (Virtual Application Networks) versus generally location-aware REST API-based services. This increases the opportunity for parallel processing of events across clusters.

Conclusion

EDA provides a number of advantages over REST APIs for modern applications deployed across hybrid cloud environments. EDA solutions mirror life better and are more readily extensible. They enable real-time responsiveness and are easy to scale up, in contrast to REST API-based architectures, where changes are harder to effect.

Leave a Reply

Your email address will not be published. Required fields are marked *