Image

What if your architecture could do lots of things at the same time? As businesses grow and become more successful, they need to be able to handle more and more users, without slowing down or crashing systems. In this chapter, you’ll learn how to design high-performance systems that can scale as a business grows. Get ready for event-driven architecture , a highly popular distributed architectural style. It’s very fast, highly scalable, and easy to extend—but it’s also quite complex. You’ll be learning about lots of new concepts in this chapter, including things like events, messages, and asynchronous communication, so you can create an architecture that can do many things at once. Fasten your seatbelt, and let’s go on an asynchronous adventure through event-driven architecture.

Too slow

Imagine going to your favorite diner to order their famous grilled cheese sandwich, crispy fries, and a chocolate milkshake. Sounds easy, right? But what if the person taking your order had to make all of those things one at a time, without any help? Not only would everything take longer, but the diner wouldn’t be able to serve as many customers. Let’s visualize that workflow:

Image

Image

This is no way to run a diner! Let’s see if we can make things go a little faster so they can serve more customers.

Brain Power

Image

Pretend you are a customer of this diner. How would you suggest they speed things up?

Note

Write your ideas here.

Speeding things up

If the diner hires three more workers (one to make the sandwiches, one to cook the french fries, and one to make milkshakes) and they prepare all parts of the meal at once, completing orders will take half as long. That effectively doubles the number of customers the diner can serve during the lunch hour.

Image

Image

Doing all three activities at the same time significantly reduces customers’ wait time (we’ll call that responsiveness ). Because meals can be made faster, the server taking orders can now handle more customers (we’ll call that scalability ).

Note

Note: we’ll be referring to event-driven architecture as EDA going forward, because we’re cool like that (and, thankfully, we don’t get paid by the word).

This is the fundamental concept behind event-driven architecture (EDA) —breaking up processing into separate services , with each of those services performing its function at the same time by responding to an event (something that just happened). In EDA, services communicate asynchronously through an event channel , meaning they don’t wait for responses from other services to complete their work.

Note

Don’t worry—we’ll cover all of these terms.

Image

We know this is a lot to take in at once, so we’ll take it step by step. But before we jump in, let us introduce you to Der Nile, a large German online-ordering company that is having growing pains and needs your help.

Der Nile flows faster than ever

Der Nile is Germany’s largest online retailer, selling everything from diapers to hair-growth supplements.

Business is booming—so much, as a matter of fact, that the company’s online ordering system is stressed to the breaking point. Der Nile’s customers demand fast systems and quick order fulfillment, and the current system simply can’t handle the volume of orders coming in. Processing orders takes too long, and fulfillment times are increasing.

Der Nile would like to create a new ordering system from scratch to handle this growth—and needs your help in designing it.

Here is the basic flow of the legacy online-ordering system currently in place:

Image

Image

Exercise

Image

As the architect, how can you modify the current workflow (shown on the previous page) to speed things up a bit? Draw your ideas for a new workflow in the space below. Hint: What can you do at the same time?

Image

Image Solution in “Exercise Solution”

What is an event?

Back in the late 1950s, a journalist asked Prime Minister Harold Macmillan of the United Kingdom what troubled him the most. “Events, my dear boy, events,” was his famous reply. Events may have troubled Harold Macmillan, but they can be a lot of help to us in solving complex business problems.

An event is something that happens, especially something of importance. Things like the World Cup, musical concerts, big promotions at work, weddings, and birthday celebrations are all important events.

Note

Publishing this book was an important event for the authors.

In software systems, certain user actions trigger events—things that happen, like placing a bid for an item up for auction, filing an insurance claim, or making a purchase.

Image

Events are a way for a service to let the rest of the system know that something important has just happened. In EDA, events are the means of passing information to other services.

Note

Friendly reminder: EDA is event-driven architecture.

An event usually contains data, like all the details of an online order. On occasion, it might only have key information (like the order ID). In the latter case, services that must do something when they receive the event will have go to a data store to get additional information about it.

Note

The data inside an event is referred to as its payload.

Image

Image

No, an event is not the same thing as a message. Although they both deliver information to other parts of the system, there are some important differences between them.

An event is used to broadcast some action that a service just performed to other services in the system. For example, a service might tell the rest of the system: A customer just placed an order. A service sending an event never waits for a response. The service generally has no knowledge about what other services (if any) are listening for that event, or what they’ll do with that information if they respond to it.

Note

This is often referred to as “fire-and-forget.”

Note

More on this soon.

A message , on the other hand, is a command , such as Apply the payment for this order , or a request , like Give me shipping options for this customer . Because messages are only meant to reach one other service, the other services in the system are unaware of the message. Services sometimes stop and wait for a response (for instance, if they are sending a request for information). Other times, the service might just issue a command and trust that the receiving service will do its job.

Turn the page to see more differences between an event and a message.

Events versus messages

Here are two really important differences between events and messages:

1. Events are broadcast to other services using topics, whereas messages are sent to a single service using queues.

Image

2. Events always broadcast something that has already happened, whereas messages request something that needs to be done.

Image

Sharpen your pencil

Image

It’s time to test your knowledge about events and messages. For each of the quotes below, mark whether it is more likely an event or a message, and indicate why.

Image

Image Solution in “Sharpen your pencil Solution”

Initiating and derived events

Events that originate from a customer or end user are called initiating events. These are a special type of event that kicks off a business process.

Once a service responds to an initiating event, it might in turn broadcast what it did to the rest of the system, within the scope of that initiating event. These events are called derived events because they are internal events generated in response to the initiating event.

Image

Did you notice that the Payment service generates two different derived events? This is typical in EDA. Anything a service generates or causes to happen can be a derived event.

Exercise

Image

Based on the Credit Card Charged initiating event and the corresponding processing below, can you identify what the derived events should be for each service? Think of as many possible outcomes as you can.

Image

Image Solution in “Exercise Solution”

Is anyone listening?

When you post something on social media, you often get a reaction—someone liking or commenting on your post. But how many times have you posted something only to get no reaction? Maybe you wondered: Did anyone see my post? Did anyone care?

In EDA, any action a service performs should trigger a derived event. However, there is a chance that no one cares about certain events. So why publish those events? Because this provides architectural extensibility — the ability to extend the system to add new functionality.

Note

Extensibility is one of the architectural characteristics you learned about in Chapter 2 .

Let’s say customers in the Der Nile online ordering system get notified when an order is shipped and also when it has been delivered. The Email Notification service handles this by sending the customer an email. That event in turn triggers a Customer Notified derived event.

Image

Now let’s suppose Der Nile wants to do some analytics to learn what times of the day the system sends the most customer notification emails. Since the Customer Notified derived event is already being published, you can simply create a new Notification Analytics service and tell it to listen for that event. You don’t need to modify any other parts of the system .

Image

Asynchronous communication

Image

Event-driven architecture is fast because it uses mostly asynchronous (or “async” for short) communication.

You’re probably most familiar with communication styles such as REST or HTTP, particularly when you need to call an API or another service. These are forms of synchronous communication . With synchronous (or “sync”) communication, when a service sends information, it must sit and wait for a response from the receiving service before doing anything else (even if it’s just acknowledging receipt of the information). This slows systems down and makes them less scalable. It’s like calling a friend—you have to wait for your phone to make a connection to your friend’s phone, let it ring, and wait for your friend to answer before you can talk.

Asynchronous communication is a fancy way of saying that services don’t wait for a response or acknowledgment from other services when sending them information. This creates systems that are highly decoupled and very fast. It’s one of the unique features of event-driven architecture. It’s like sending your friend a text—you can do other things while you wait for their response.

Image

Image

Fireside Chats

Image

Tonight’s talk: Asynchronous and synchronous communication debate: Who’s more useful?

Asynchronous CommunicationSynchronous Communication
Well, it’s about time you showed up.
Sorry I’m late. I can’t seem to multitask, so everything I do takes such a long time.
Yeah, I’ve noticed. You’re as slow as a herd of snails traveling through peanut butter.
Now, wait just one minute!
Wait? You want me to wait? That’s your whole problem—you’re always waiting around for answers. No one has to wait when I’m around. And that makes me fast— really fast.
That may be so, but your problem is that you never know what’s going on. You ask others to do things, but you never find out whether those things actually got done or not.
I trust others to get the job done, unlike you. You need verification for everything , all the time.
Yeah, right. Tell me: when an error occurs downstream, how do you deal with it?
I don’t. I can’t be responsible for everyone, you know. I let others deal with their own issues.
And what if you need information from someone else before you can finish your work? What do you do then?
Oh, I’m sorry—did you say something? I wasn’t listening.
That’s exactly my point! You never listen to anyone else. I may be slow, but at least I pay attention to what’s going on and communicate with others.
Sorry—I wasn’t paying attention. What was that?
Sigh...

Fire-and-forget

Asynchronous communication is one of the foundations of event-driven architecture. When a service broadcasts information to other services, it doesn’t wait for a response, nor does it care whether the services are available or not. This is known as fire-and-forget communication—the event is sent (that’s the fire part), and the service moves on to do other things (that’s the forget part). Architects usually use a dotted line to represent async communication between services.

Image

Synchronous communication, on the other hand, means that the sending service must stop and wait for a response from the service it’s calling before continuing its work. This means that the service being called must be available to respond, or an error occurs. Architects usually represent synchronous communication using a solid line.

Image

Event-driven architecture relies on asynchronous communication when sending and receiving events.

Sharpen your pencil

Image

For each of these tasks, would you use asynchronous or synchronous communication?

Give me the shipping options for this order.

Image AsynchronousImage SynchronousImage Either one would work

Apply payment for this order and let me know if the payment goes through.

Image AsynchronousImage SynchronousImage Either one would work

Fulfill this order for me by picking the items off the shelf and packing them in a box.

Image AsynchronousImage SynchronousImage Either one would work

Give me the current status of this order.

Image AsynchronousImage SynchronousImage Either one would work

Our inventory of this item is getting low—please order more stock.

Image AsynchronousImage SynchronousImage Either one would work

Tell the customer that their order has been shipped and is on its way.

Image AsynchronousImage SynchronousImage Either one would work

Update the customer’s profile picture.

Image AsynchronousImage SynchronousImage Either one would work

Post a customer’s review on the product page.

Image AsynchronousImage SynchronousImage Either one would work

Image Solution in “Sharpen your pencil Solution”

Asynchronous for the win

Communicating between services asynchronously has a lot of advantages. The first is better responsiveness —in async, it takes less time to complete a request.

Suppose a customer places an online order in Der Nile. It takes 600 milliseconds (ms), or just over half a second, for the Order Placement service to validate and place the order, and 1,200 ms for the Payment service to apply the payment. With async, the customer would wait 600 ms to get a response. With sync, however, they would have to wait 1,800 ms (just shy of 2 seconds). That’s a big difference in response times.

Image

The other big advantage of async is availability . Let’s see what happens with async and sync if the Payment service is unavailable or becomes unresponsive.

Image

Have we convinced you that asynchronous communication is great? Let’s take a look at its trade-offs next.

Note

Remember the First Law—everything in software architecture is a trade-off.

Synchronous for the win

The main disadvantage of async communication is error handling . With sync communication, if there’s a problem with the payment method, the customer knows right away and has a chance to fix it and resubmit the order. However, with async, the customer thinks everything is fine because the system hasn’t told them otherwise—but the Order Placement service can’t process the order until the customer corrects the payment problem. This makes error handling much more complex.

Image

Sharpen your pencil

Image

Now’s your chance to test what you’ve learned so far about event-driven architecture, events, and asynchronous processing. Der Nile’s inventory occasionally gets out of sync, as shown below. When this happens, the order cannot be fulfilled and goes into a back-order state. Der Nile never makes a customer pay for items that are back-ordered, and the customer can choose whether to wait or cancel the order.

As the architect for Der Nile, what additional events and services would you create to address this situation?

Image

Image Solution in “Sharpen your pencil Solution”

Database topologies

Image

We’re glad you brought that up.

Data can be a complex topic in EDA. Because EDA is so asynchronous, services are highly decoupled from one another . However, if all the services share a single database, then they end up being highly coupled to the database . On the other hand, if each service owns its own data, like with microservices (discussed in the previous chapter), then services become highly coupled to each other because they need to synchronously ask each other for the data. In either case, data forms a coupling point—something we try to avoid in EDA.

In the next couple of pages we’re going to show you various ways for dealing with databases in EDA: monolithic databases , domain-partitioned databases , and the database-per-service pattern. We’ll talk about their trade-offs to help you decide which one is most appropriate for your situation.

Monolithic database

In the monolithic database topology, all services share a single database. The main advantage is that when services need data they don’t own, they can go directly to the database. This means they don’t have to make synchronous calls to other services to get data. For example, if the Order Placement service needs the current inventory and shipping options for a customer’s order, it can simply query that information from the database.

Image

However, this decoupling comes with a steep price: managing database changes . Because all services share the same database, when you make a change to the structure of one table, it’s difficult to identify all the services that change will affect. Testing and releasing becomes a tricky game—one you will all too often lose. This leads to brittle systems that are difficult to maintain.

What’s more, the shared database becomes a single point of failure, and one that may not be able to scale as the system grows.

Monolithic database topology scorecard

Here’s a scorecard for the monolithic database topology.

Image

Domain-partitioned databases

With domain-partitioned databases, each domain in the system has its own database. This means any service that belongs to a particular domain will share the database for that domain. For example, the Order Placement, Payment, and Inventory services are all part of the Order Placement domain, so they all share the same physical database.

However, since each domain forms its own broad physical bounded context, a service in one domain can’t directly access a database to get data from another domain. This means it must make a synchronous call to another service to get the data—and now these services are coupled.

Note

See Chapter 10 for a review of the physical bounded context.

Image

This topology is a well-balanced, middle-of-the-road solution within event-driven architecture.

Domain-partitioned databases topology scorecard

Here’s a scorecard for the domain-partitioned databases topology.

Image

Database-per-service

Remember the database-per-service pattern from Chapter 10 ? It isn’t just for microservices—you can use it for EDA as well.

The database-per-service pattern is just what it sounds like. Every service has its own database, forming an even tighter physical bounded context than with the domain-partitioned topology. Here, making database changes is a breeze, because the only service affected is the one that owns the data (that is, does writes to the database). You get better fault tolerance and better scalability, too. What’s not to like?

Note

We hope you have plenty of money! This can get expensive.

Unfortunately, plenty. You see, whenever services need additional data they don’t have, they have to ask for that data from the service that owns it using synchronous calls. That results in a lot of coupling and communication between services, not to mention much slower performance.

Image

Database-per-service topology scorecard

Here’s a scorecard for the database-per-service topology.

Image

Exercise

Image

For each of these business needs, select which topologies you would consider. You can select more than one topology.

We expect anywhere between 20 and 300,000 customers to be on the system at once.

Image Monolithic DatabaseImage Domain-Partitioned DatabasesImage Database-Per-Service

The system must be as fast as possible.

Image Monolithic DatabaseImage Domain-Partitioned DatabasesImage Database-Per-Service

This medical monitoring system can never completely fail—parts of it must always stay running.

Image Monolithic DatabaseImage Domain-Partitioned DatabasesImage Database-Per-Service

We’re anticipating changing the database a lot in this new line of business.

Image Monolithic DatabaseImage Domain-Partitioned DatabasesImage Database-Per-Service

We have to get the new system up and running as soon as possible.

Image Monolithic DatabaseImage Domain-Partitioned DatabasesImage Database-Per-Service

Our data model is extremely large and complex, with lots of interrelated data.

Image Monolithic DatabaseImage Domain-Partitioned DatabasesImage Database-Per-Service

Image Solution in “Exercise Solution”

Image

Even though they may appear simliar, EDA and microservices are very different.

We’re glad you noticed some similarities between the two architectural styles. Both are distributed architectures good for scalability, agility, elasticity, and fault tolerance.

Over the next few pages, we’ll show you some important differences. But before we move on, how about trying the short exercise below to see if you can spot any yourself?

Sharpen your pencil

Image

List any differences you can think of between event-driven architecture and microservices.

Note

If you don’t know, that’s okay—keep reading!

Image Solution in “Sharpen your pencil Solution”

EDA versus microservices

Welcome to the EDA versus microservices Top Six Differences countdown! Over the next few pages, we’re going to count down six important differences between these architectural styles, starting with number 6. Ready? Let’s go!

Note

It’s time for the Head First differences countdown!

Number 6: Performance

The first difference in our countdown, at number 6, is performance .

In their book Fundamentals of Software Architecture (O’Reilly), two of your authors created star ratings for each architectural style. We gave microservices only two stars out of five for performance, but we gave EDA five stars. Why?

Image

Well, EDA combines asynchronous processing with the ability to do multiple things at once, creating very fast systems. Microservices, however, because of their bounded contexts and fine-grained nature, frequently need to communicate synchronously . This creates a lot of latency, which slows the system down considerably.

Image

Number 5: Physical bounded contexts

Coming in at number 5 in our countdown is physical bounded contexts . Microservices won’t work without these.

In EDA, however, while a physical bounded context is nice to have, it’s certainly not foundational (or even required). Because data sharing is pretty typical in EDA, this architecture doesn’t restrict data ownership as strictly as microservices does.

Image

Number 4: Data granularity

Another constraint with microservices that doesn’t exist in EDA is data granularity .

By definition, a microservices architecture requires each service to own its own data. This means you have to break apart your data into fine-grained databases or database schemas —collections of tables that a service owns (writes to). But in EDA, you can choose a single monolithic database, domain-partitioned databases, or the database-per-service pattern.

Note

You can refresh your memory of this restriction and why it exists by going back to Chapter 10 .

Image

Number 3: Service granularity

Number 3 in our differences countdown has to do with service granularity . Recall from Chapter 10 that a microservice is a single-purpose service that does one thing really well . As a result, microservices tend to be fine-grained.

EDA has no such restrictions. Services in an event-driven architecture (formally called event processors ) can be whatever size they need to be—fine-grained, coarse-grained, it doesn’t matter.

Image

Number 2: Event versus request processing

We’re almost there. Coming in at number 2 is another fundamental difference: event processing versus request processing . Event-driven architecture is built on event processing —responding to something that has happened, and in turn triggering more events. Microservices architecture, on the other hand, is built on request processing —responding to something that needs to happen, like a command or a request, and processing that request.

Image

Number 1: Communication style

And finally, coming in at number 1 is the most fundamental difference between EDA and microservices: communication style. EDA typically uses asynchronous communication between services, whereas microservices typically rely on synchronous communication using REST. EDA can occasionally use synchronous calls for things like retrieving data it doesn’t have access to, and microservices can use asynchronous communication when commands don’t require a response. But those are exceptions rather than the rule.

Image

Who Does What?

Oh dear! We tried to organize these facts , but got them all mixed up. Can you help us figure out which statements are about EDA and which are about microservices? Careful—some facts apply to both.

Image

Image Solution in “Who Does What? Solution”

Hybrids: Event-driven microservices

Even with all the differences between EDA and microservices, there’s no reason you can’t combine them. Doing this creates a hybrid architecture called event-driven microservices .

Note

A hybrid architecture combines multiple architectural styles.

You might have observed that the EDA database-per-service pattern for Der Nile looks a lot like microservices. However, just using the database-per-service pattern doesn’t make it event-driven microservices. To see what we mean, take a look at this EDA.

Image

Sharpen your pencil

Image

The above architecture is an acceptable and well-formed EDA, but not a well-formed microservices architecture. Two fundamental principles are missing that would make it event-driven microservices. Can you list what those two missing things are?

Image

Image Solution in “Sharpen your pencil Solution”

To make this architecture an event-driven microservices hybrid, we have to apply two very important principles of microservices: single-purpose services and physical bounded contexts.

The Order Submission service has to accept an order, validate it, apply the payment, and adjust the inventory. It’s certainly not a single-purpose service. That’s perfectly acceptable in EDA, but not in microservices. The same is true of the Order Fulfillment service. To make this an event-driven microservices architecture, we’d have to split these services into separate single-purpose services, each triggering its own events.

Image

You might have noticed on the previous page that the Email service is accessing the Order Submission database directly. In microservices, this isn’t allowed because of the physical bounded context. In the new hybrid architecture, to retrieve the order data, the Email service needs to call the Order Submission service (now the Order Placement service, since we broke that service up). The implementation of tight physical bounded contexts isolates data access to the owning service.

Event-driven architecture superpowers

It’s time to check out the superpowers of the EDA style.

Image

Maintainability

Services in EDA are highly decoupled, making them fairly independent and therefore easier to maintain.

Image

Performance

Because EDA mostly uses asynchronous communication and can multitask, it’s very fast.

Image

Scalability

Event-driven architectures are highly scalable because of asynchronous processing and service decoupling. Each service can scale independently of others, with the event channels acting as pressure release valves if bottlenecks occur.

Evolvability

EDA services always trigger derived events, onto which we can easily add functionality. This makes EDA highly evolvable.

Image

Fault tolerance

Because services are highly decoupled in EDA, if one service goes down, it doesn’t bring down other services in the workflow.

Event-driven architecture kryptonite

Kryptonite diminishes a superhero’s powers, just like these system features and characteristics diminish the power of EDA. Watch out for them!

Image

Image

Complexity

EDA is highly complex because it typically uses asynchronous communication and parallel event processing, and because of its varied database topologies and their trade-offs.

Testability

It’s really hard to test asynchronous processing and parallel tasks, making testability a weakness in EDA.

Image

Synchronous calls

If you have lots of synchronous calls between services and workflows that require synchronously dependent services, EDA is not for you.

Databases

Regardless of the database topology you choose, services are coupled: either to the database or to each other. There are not a lot of good trade-offs here.

Note

We know you need a database—what we’re saying here is that databases can couple an otherwise highly decoupled system.

Image

Event-driven architecture star ratings

Below is a useful chart for better understanding what EDA is good at and what it’s not so good at. One star means that the architectural characteristic is not well supported; five stars means it’s very well supported.

Note

Just like movie reviews.

Image

EDA is great for operational characteristics like performance, scalability, elasticity, evolvability, and fault tolerance, but struggles when it comes to simplicity and testing. Asynchronous communication is hard to test, and it’s also hard to verify that a change in one service or event hasn’t affected other services.

Exercise

Image

Which of the following systems might be well suited for the event-driven architectural style, and why? Hint: Think about EDA’s superpowers, its kryptonite, and the problem domain.

Image

Image Solution in “Exercise Solution”

Putting it all together

Now, the part you’ve been waiting for—the complete picture of the Der Nile online ordering system using event-driven architecture. Since there are lots of database topologies to choose from, we’ll focus on the core parts of the system: event processors (services) and events.

Image

Wrapping up

Well done! Thanks to your diligent work and EDA knowledge, Der Nile is scaling up and performing to meet its high customer demand, with room to grow even more. Let’s close this chapter by reviewing some key points about event-driven architecture.

Bullet Points

  • An event is something that happens in the system. Events are the fundamental way services communicate with each other in EDA.

  • Events are not the same thing as messages— events broadcast some action a service just performed to other services in the system, whereas messages are commands or requests directed to a single service.

  • An initiating event originates from a customer or end user and kicks off a business process.

  • A derived event is generated by a service in response to an initiating event.

  • Any action a service performs should trigger a derived event to provide architectural extensibility —the ability to extend the system to add new functionality.

  • EDA is fast because it generally uses asynchronous (async) communication —services don’t wait for a response or acknowledgment from other services when sending them information.

  • Asynchronous communication is sometimes called fire-and-forget .

  • Architects usually use a dotted line to represent async communication between services and a solid line to represent sync communication.

  • Unlike microservices, event-driven architecture can use a variety of database topologies:

    • With the monolithic database topology, all services share a single database.

    • With the domain-partitioned databases topology, each domain in the system has its own database, shared by all of the services within that domain.

    • In the database-per-service pattern , each service has its own database in a bounded context.

  • Event-driven architecture and microservices are very different architectural styles:

    • EDA relies mostly on asynchronous communication between services, whereas microservices typically rely on synchronous communication using REST.

    • EDA is built on event processing —processing things that have already happened. A microservices architecture is built on request processing — processing a command or request about something that needs to happen.

    • Microservices are fine-grained and single-purpose, whereas services in EDA can be any size.

    • Microservices requires each service to own its own data, whereas in EDA services can (and usually do) share data.

  • You can combine microservices and EDA to create a hybrid architecture called event-driven microservices .

  • EDA is very complex because it uses asynchronous communication and parallel event processing, and has varied database topologies.

  • It’s really hard to test asynchronous processing and parallel tasks, making testability a weakness in EDA.

  • Derived events provide hooks to add functionality, making EDA highly evolvable.

  • EDA is highly scalable because of asynchronous processing and service decoupling.

Event-Driven Crossword

Image

Ready to have some fun and test your knowledge about events, asynchronous communication, event processors, and multitasking? Try this crossword puzzle about the event-driven architectural style.

Image

Across

2. How each part of a process is completed and in what order

3. _____-and-forget communication

5. When you combine a service with a database, you get a physical bounded _____

6. Reducing users’ wait time is the goal of making a system more _____

8. Async communications don’t _____ for a response

12. Type of communication that requires a response

13. Architectural characteristic that deals with speed

18. Some architectures are easier to _____ with new features

19. These communications are sent to a single service using queues

20. Certain conditions may _____ an event

Down

1. A way of organizing databases in an architecture

4. Something important that happens

7. Type of event that kicks off a business process

9. Type of event that flows from other events

10. Abbr. for an external communication hub that an app may call

11. An event is used to _____ news that something has happened

12. Part of an architecture that performs a function

14. _____-partitioned databases

15. Events are delivered via an event _____

16. A message can be a command or a _____

17. Services can _____ for event notifications

Image Solution in “Event-Driven Crossword Solution”

From “Exercise”

Exercise Solution

Image

As the architect, how can you modify the current workflow shown in “Exercise” to speed things up a bit? Draw your ideas for a new workflow in the space below. Hint: What can you do at the same time? Here’s our solution.

Image

From “Sharpen your pencil”

Sharpen your pencil Solution

Image

It’s time to test your knowledge about events and messages. For each of the quotes below, mark whether it is more likely an event or a message, and indicate why.

Image

From “Exercise”

Exercise Solution

Image

Based on the Credit Card Charged initiating event and the corresponding processing below, can you identify what the derived events should be for each service? Think of as many possible outcomes as you can. Here’s our take.

Image

From “Sharpen your pencil”

Sharpen your pencil Solution

Image

For each of these tasks, would you use asynchronous or synchronous communication?

Image

From “Sharpen your pencil”

Sharpen your pencil Solution

Image

Now’s your chance to test what you’ve learned so far about event-driven architecture, events, and asynchronous processing. Der Nile ’s inventory occasionally gets out of sync, as shown below. When this happens, the order cannot be fulfilled and goes into a back-order state. Der Nile never makes a customer pay for items that are back-ordered, and the customer can choose whether to wait or cancel the order.

As the architect for Der Nile, what additional events and services would you create to address this situation?

Image

From “Exercise”

Exercise Solution

Image

For each of these business needs, select which topologies you would consider. You can select more than one topology.

Image

From “Sharpen your pencil”

Sharpen your pencil Solution

Image

List any differences you can think of between event-driven architecture and microservices.

  • Performance

  • Physical bounded contexts

  • Data granularity

  • Service granularity

  • Event vs. request processing

  • Asynchronous versus synchronous processing

    Note

    These are some of the ones we came up with.

From “Who Does What?”

Who Does What? Solution

Oh dear! We tried to organize these facts, but got them all mixed up. Can you help us figure out which statements are about EDA and which are about microservices? Careful—some facts apply to both.

Image

From “Sharpen your pencil”

Sharpen your pencil Solution

Image

The architecture in “Sharpen your pencil” is an acceptable and well-formed EDA, but not a well-formed microservices architecture. Two fundamental principles are missing that would make it event-driven microservices. Can you list what those two missing things are?

Image

From “Exercise”

Exercise Solution

Image

Which of the following systems might be well suited for the event-driven architectural style, and why? Hint: Think about EDA’s superpowers, its kryptonite, and the problem domain.

Image

Event-Driven Crossword Solution

Image

From “Event-Driven Crossword”

Image