Event-Driven Design Patterns of the '90s Are Here Again

Event-Driven Design Patterns of the '90s Are Here Again.jpg

Event-driven design patterns are seeing a resurgence in recent years. From Airbnb to Netflix and Amazon, event-driven patterns are used in almost every tool, platform, and service to provide users with an experience that is fast, reliable, and secure. 

But event-design patterns didn’t just pop up like the iPhone in the 2000s. They have been around for decades, waiting for the right moment to shine. They are allowing organizations to build large-scale solutions that create the experiences modern users are looking for. 

So what led to their adoption now? 

To understand this, we first need to go back to the '90s, when object-oriented new technologies first became popular. 

The evolution of event-driven design patterns

In the 1990s, object-oriented (OO) methods gradually eclipsed the structured methodology of the 1970s and 1980s. Their popularity grew when the Gang of Four (Gamma et al.) published “Design Patterns: Elements of Reusable Object-Oriented Software." The book identified 23 recurring design patterns used by development and software engineering teams to solve common problems. However, event-design patterns were years away from becoming a formalized concept.

In the 2000s, the milestone of the internet let individuals and businesses interact with a much wider audience using web applications powered by application programming interfaces (APIs). Initially, APIs used a request-response approach to mimic real-world processes like placing an order, making payments, and sending messages. But this approach had a fatal flaw: If one endpoint stopped working, the entire ecosystem would crash.

Developers looked to event-driven design patterns to circumvent this flaw because its decoupled nature allowed services to send and receive messages asynchronously. Applications could now work even if one service was out of commission. Also, event-driven patterns were flexible, which allowed businesses to get really creative when solving their problems and building enhancements.

Common event-driven design patterns (with examples)

If they have the infrastructure to support them, organizations can choose from a number of event-driven design patterns that serve a range of use cases.

Publisher/subscriber pattern

The publisher/subscriber (pub/sub) pattern is the most basic and widely used pattern for event-driven architectures. The make up of this pattern allows subscribers and publishers to communicate with each other asynchronously via an intermediary called the event broker. Publishers produce events and send them to the broker, while subscribers register their interest in certain events and receive them from the broker.

Pub/sub patterns provide the following benefits: 

Use case: delivery logistics

According to Statista, package shipping volume reached 21.6 billion parcels in 2021. To keep up with higher level demands, logistics companies have to use their resources more efficiently. They need to predict arrival times more accurately and improve routing solutions using the driver’s location, traffic data, cancellations, and even new pickups. 

But this is a lot of data to process quickly, especially as the day goes on and more information comes in in real time. Devices need to be able to subscribe to information relevant to them. The pub/sub pattern ensures that only relevant data is delivered to these systems by subscribing only to them. For example, drivers’ devices subscribe to traffic and route information, enterprise resource planning (ERP) systems can subscribe to delivery updates, etc.

Case study: Mothership Modernizes Freight Shipping with Real-Time Data

Event streaming pattern

The event streaming pattern allows systems to process and analyze a large number of events in real time or near real time. It uses a stream processing engine to consume an event from a source, transforms them using predefined logic, and stores the new event in an event sink.

Event streaming provides real life benefits like:

Use case: Internet of Things (IoT) devices

Farmers use IoT devices to collect and store data and monitor their crops. The data allows them to make data-driven decisions to improve their efficiency and crop yield. Event streaming enables farmers to connect and share this data in real time to end users, letting them make decisions faster. For example, farmers can instruct the system to notify them if a specific mineral in the soil exceeds the preferred amounts so they can take preventive measures before it affects the crops.

Case study: Climate LLC Helps Farmers Increase Productivity

Event sourcing pattern

Event sourcing patterns define a way to manage operations on data that follow a specific sequence of events. New events are stored chronologically in an append-only event store. The event store usually publishes these events so that subscribers are notified and can initiate any related tasks.

Event sourcing provides benefits like: 

Use case: e-commerce stores

Event sourcing is a great way to track your store inventory in your e-commerce store. You have an immutable record of every purchase, return, and payment status in one place. You can also use the data to create a much better user experience collected on each item to understand your audience. 

This lets you identify trends (like your most popular items) and make decisions to improve your business. 

Case study: Stage TEN Lets Creators Produce Live E-Commerce Events

The era of event-driven patterns

Event-driven patterns have been around since the '90s. But organizations didn’t see the need to implement such infrastructure until now. Modern consumers are looking for real-time experiences without any major disruptions, and event-driven patterns are the answer to that. 

However, implementing these solutions at scale is a complex endeavor. Your best bet is to offload this work to a third party with the required experience. Contact our sales team or start your free trial to experience how PubNub enables real-time interactions on your apps and IoT devices.