Event-Driven Architecture in Software Development- Its uses cases
Event Driven Architecture in Software Development
Event-driven architecture or EDA is a pattern or a design in which a software is created. It is an event driven activity through which can organisation can detect an “event” happening for eg a transaction, website clicks, shopping etc, in a real time basis. An event refers to a significant occurrence in the hardware or software. Some examples can be request to reset password, unauthorised access denied, non-availability of inventory etc. This type of software design is capable of ruling out the traditional way of sending and receiving actions. The EDA is designed in a such a way so it can respond to events happening and to carry out actions in response to the event in a way of automation.
It is also known an “asynchronous”, which means that the sender and the receiver need not have to wait for one another’s move into the next steps. Systems can perform the task itself without waiting for the response. Most of the modern application designs are Event Driven architecture such as CRM that utilises customer data in real time. With an event-driven architecture when a notification is sent the system captures the information and follows the required process to come out with an output.
Arrival of EDA over the years.
Traditionally most of the systems operated in a data centric model where the data source is core but the technology is now moving towards event-driven architecture rather than a data centric model. The EDA also mentions data to important but the event is the most important component. The shift to event-driven architecture happened since with the advent of technology focussed more on responding to events when they happen. Since it is very important to note that quick response is the key for events because the older the events are they become less valuable. Service oriented architecture and Event-driven architecture are mostly used together.
EDA uses a log analogy for keeping track of events happening. If one wants to find out happened in the past they can easily go back and check the log, Whereas the data centric model mostly focus on data. In an event-driven architecture events producers can be one who generate the evens but the notifications can have one or more consumers or receivers, receiving the trigger. This is different from the traditionally used system of request-reply messaging system.
The Process of Event-driven architecture
There are three components of an EDA: Producers, Consumers and Brokers. An event producer is someone who detects or senses an event or represent the event does not know about the consumer. As soon as the event happens it is transmitted to the consumers through channels or event platforms. Event consumers are informed about the event had occurred, in that case they may either process the event or might not be effected by the same. The processing platform will process the correct event to the right consumers. The broker is an option part specially in cases where there are single producer and single consumer. Most commonly there are always one or more consumer interested in a particular event.
The components of an event-driven architecture can include three parts: producer, consumer, broker. The broker can be optional, particularly when you have a single producer and a single consumer that are in direct communication with each other and the producer just sends the events to the consumer. An example would be a producer that is sending only to a database or data warehouse so the events are collected and stored for analysis. Most commonly in enterprises, you have multiple sources sending out all types of events with one or more consumers interested in some or all of those events. For Example a live streaming platform has a single producer but multiple consumers driven by the event.
Understanding the Pub/Sub Models
The Concept of EDA is realised through the publish/subscribe communication model. It is flexible messaging pattern that allows system components to interact with each other. The pub/sub enables the computer to react to an event or a data as they occur. When an event occurred the router ensures the subscriber receives. The idea of Interaction remains the same.
Lets take an example of a Pizza Ordering system. It follows a pub-sub model. Roughly the event flow can be mentioned below:-
- The user orders pizza from their user profile. The data related to user’s name, quantity, location, contact info etc for delivery is captured.
- The food delivery service received the information and reacts to the ordering pizza event.
- The restaurant partner which is subscribed to this event fulfils the order and publishes about the order being ready.
- The food delivery partner sends the information the nearest deliveryman respectively and it notifies the customer about the update on the delivery.
The data exchange logic in the pub-sub model works in the following system.
Use Cases of Pub/Sub Model
Below are few of the uses cases for Pub/Sub Model in Event-driven architecture.
Online shopping involves a lot of activities and EDA can bring them all together. Events broadcasting happens at each stage from order placement to shipment allowing real time reaction.
Healthcare uses a huge amount of data generated from different devices such as IOT, wearables and other equipments in real time. The event driven approach allows processing the data in a timely fashion for monitoring and in a more proactive way.
Online banking is also maintained by With event-driven architecture to monitor transaction in real-time to avoid fraud activity as it happens by notifying the customer about any suspected transaction.
In Internet of Things events are captured from devices on data such as temperature reading, location points etc. EDA allows for processing huge volumes of data from IoT-based environments and devices the moment it is generated.
Some Example of Pub/Sub Model
Google Cloud Pub/Sub– It is a messaging service designed to provide reliable messaging between applications. It is a fully-managed messaging service.
Amazon SNS– Amazon simple Notification service or Amazon SNS is a managed service that provides message delivery from producers to consumers. These applications include Amazon Simple Queue Service (SQS), Amazon Kinesis Data Firehose, AWS Lambda etc.
Redis Pub/Sub: It implements a real-time messaging system in which publishers publish their messages to a channel or topic and several clients can subscribe to that topic.
Understanding the Event- Streaming Architecture Model
Event streaming is a type of subscription-based pattern. In this way, events are written in logs, all the consumers can read through the log to identify the events at any point of time or any part of the stream and can replay it anytime.
The Pattern of Event processing
There are different patterns through which the events reaches its customers. Some of them are below:-
- In Simple event processing the consumers process events at each interval as it is received. Ecommerce is an example of such processing.
- In Complex event processing the Consumers process a series of events to detect patterns in the data.
- In Event stream processing the Data streaming platforms ingest the stream processors that send data to consumers.
Use Cases of an event streaming architecture
A Use cases of an event streaming architecture can be cases like payment processing, fraud detection, anomaly detection etc which all reply on immediate actions. All of these deals with a data point in a continuous stream associated with a specific point. These are examples of event stream processing. It is also important when the data granularity is critical. As for an example the actual changes in stock price is very important to a trader than the price of the stock price, event processing stream is capable of tracking the rea; time changes which helps in making better trading decisions. The CDC, downstream systems uses the stream of individual updates to a database for purposes such of identifying usage patterns that can help define optimization strategies.
Some Examples of Stream based Platform:
- Apache Kafka is a platform which is based on distributing streaming process. It is system which lets exchanging of data between applications, servers and processors.
- Apache Flink is an open-source distributed engine for stateful processing. It is designed for low latency processing for high availability and to scale horizontally. Its features include advanced state management.
- Amazon Kinesis is a scalable and cloud based service that allows real time processing of large amount of data per second. Amazon Kinesis helps in easing out collecting, processing and analysing real-time streaming data.
Understanding Message Queue
A Message Queue allows users to communicate by sending messages to each other.. It is a type of asynchronous communications protocol, in which a system that puts the message into the queue and does not require an Immediate response. An example of such is an Email communication. As soon as the email is sent the sender sends it without needing an immediate response from the receiver. This is a way of handling messages that decouples the producer from the consumer so that they do not need to interact with the message queue at the same time.
Use Cases of a Messaging queue
Suppose there is a web service that receives many requests at the same time and no requests can get lost and all other requests needs to be processed by a function. The service always needs to be highly available at all time to receive new request. In this case placing a queue in the web service and processing is the ideal option. The service can put “start processing” and the other process can handle messages in order. The processes are decouples and do not need to wait for each other. The two processes are decoupled from each other and do not need to wait. The queue will stay stay even if the number grows. As the business workload increases the system also need to be scaled up.
Examples of Messaging Queue
- RabbitMQ– It is the most widely deployed messaging broker. It is lightweight and also easy to deploy on cloud. It supports multiple streaming at the same time. It is configured to meet high-scale requirements.
- Amazon SQS- It offers a secure and durable, hosted queue that helps in integrating decoupled distributed software systems. It offers common constructs and also provides a generic web services.
When to go for Event Driven Architecture :
- Event driven architecture is useful when there is a need to run multiple systems to response to an event. The respective router will process the events differently for different process.
- Event driven architecture is helpful when there is a need to have a continuous tracking and monitoring of resources so EDA can alert any change happening on real time basis.
- Event driven architecture is also useful if the system has to run on multiple stacks. The event router in that case will take the responsibility for interoperability among the different systems
Conclusion:
Implementation of EDA can be highly beneficial for event driven structure but it is complex to implement because of its asynchronous operation distribution model. Apart from this the architecture is flexible and can be easily replaced and its highly responsive. If the expertise is right EDA can be highly applicable for event driven software choices. Considering the current situation of high amount of data Event driven architecture can be the choice of future. Bluelupin Technologies provides cutting edge agile technologies to meet the new age client requirements.