...

/

Event-Driven Architecture Protocols

Event-Driven Architecture Protocols

Let's learn about protocols that are used in different event-based communication architectures.

Motivation

The HTTP protocol is suitable for transferring data between client and server. However, for real-time communication, such as instant messaging, live streaming, gaming, and so on, HTTP falls short due to the connection terminating after a response from the server. The HTTP-based techniques to fetch updated data also have limitations. For example, short polling sends too many unnecessary requests, long polling uses two separate connections for sending and receiving data, and HTTP streaming allows only half-duplex communication. Event-driven architecture addresses all these limitations of HTTP-based techniques.

Event-driven architecture

Event-driven architecture (EDA) is an approach that centers around events for data and applications. The event-driven architecture enables applications to act or react to those events. A client gets the data whenever an event is triggered in the application without requesting the server. The problems associated with short and long polling are eliminated by using an event-driven approach. This is very much in contrast with the traditional REST API approach to request the updated data after a certain interval or when needed. The illustration below explains the concept.

Note: The event-driven protocols require the client to subscribe to a particular topic for receiving event updates, often specifying the endpoint (a callBack URL) to post the updates. The callBack method via link allows connecting directly with the host even if it is not accessible via IP address. This URL is unique for each subscription. The pub-sub uses functionality of capability URLsCapability URL restricts access only to the owner of that URL. It allows the user of that URL to access resources associated with it. to define callback URLs.

In these cases, the client wants to be informed that something has happened. In this case, there is no request or asking paradigm (which explains that the client wants to be informed about the events without sending a request (request/asking) to the server); therefore, no response is expected. An example of this can be a user posting on Instagram. The followers get notified about the post, the reactions to the post, and the posted comments, along with the event payload with each notification. Event payload or message payload is some extra information sent alongside an event ...