Chapter 8. Stateful Event-Driven Microservices
Event-driven microservices (stateful or not) typically follow the same three basic steps:
-
React to the event; e.g., from an input stream, a remote request from a client, a sensor reading, or a row insertion to a database.
-
Process that event.
-
Produce any resultant output events.
There’s a lot of detail that’s missing from this simple list, but it shows the heart of how the vast majority of event-driven microservices operate. This chapter digs deeper into the role that state plays, particularly as most microservices must maintain some degree of state to actually do anything useful.
This three-step list is important in evaluating state for event-driven microservices, particularly as the services scale, fail, and recover. How do we ensure that the correct partitions are assigned to correct consumer instances? And how do we handle multiple streams, each with their own partitioning and partitioners? This chapter will provide you the answers.
State stores play an important role in the vast majority of event-driven microservices, and go hand-in-hand with stream partition assignments. They are, quite frankly, essential for performing any business functionality beyond just toy-level complexity. Each microservice is responsible for maintaining its own state, including creating it, updating it, reading it, and destroying it.
Event-Stream Partitions and Consumer Assignments
“The Basics of Event-Driven Microservices” introduced the concept ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access