Digital Library

Building Event-Driven Microservices Leveraging Organizational Data at Scale (Adam Bellemare)(Z-Library)

Adam Bellemare

Building Event-Driven Microservices Leveraging Organizational Data at Scale (Adam Bellemare)(Z-Library)

Author Adam Bellemare

Web技术

Organizations today often struggle to balance business requirements with ever-increasing volumes of data. Additionally, the demand for leveraging large-scale, real-time data is growing rapidly among the most competitive digital industries. Conventional system architectures may not be up to the task. With this practical guide, you’ll learn how to leverage large-scale data usage across the business units in your organization using the principles of event-driven microservices. Author Adam Bellemare takes you through the process of building an event-driven microservice-powered organization. You’ll reconsider how data is produced, accessed, and propagated across your organization. Learn powerful yet simple patterns for unlocking the value of this data. Incorporate event-driven design and architectural principles into your own systems. And completely rethink how your organization delivers value by unlocking near-real-time access to data at scale. You’ll learn: * How to leverage event-driven architectures to deliver exceptional business value * The role of microservices in supporting event-driven designs * Architectural patterns to ensure success both within and between teams in your organization * Application patterns for developing powerful event-driven microservices * Components and tooling required to get your microservice ecosystem off the ground

Format PDF
Size 10.4 MB
14
Views
0
Downloads
0.00
Total Donations

Text Preview (First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
Adam Bellemare Building Event-Driven Microservices Leveraging Organizational Data at Scale
Page 2
(This page has no text content)
Page 3
Adam Bellemare Building Event-Driven Microservices Leveraging Organizational Data at Scale Boston Farnham Sebastopol TokyoBeijing
Page 4
978-1-492-05789-5 [LSI] Building Event-Driven Microservices by Adam Bellemare Copyright © 2020 Adam Bellemare. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Acquisitions Editor: Melissa Duffield Development Editor: Corbin Collins Production Editor: Christopher Faucher Copyeditor: Rachel Monaghan Proofreader: Kim Wimpsett Indexer: Potomac Indexing, LLC Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: O’Reilly Media, Inc. August 2020: First Edition Revision History for the First Edition 2020-07-02: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781492057895 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Building Event-Driven Microservices, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. The views expressed in this work are those of the author, and do not represent the publisher’s views. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
Page 5
Table of Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii 1. Why Event-Driven Microservices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 What Are Event-Driven Microservices? 2 Introduction to Domain-Driven Design and Bounded Contexts 3 Leveraging Domain Models and Bounded Contexts 4 Aligning Bounded Contexts with Business Requirements 5 Communication Structures 6 Business Communication Structures 7 Implementation Communication Structures 7 Data Communication Structures 8 Conway’s Law and Communication Structures 9 Communication Structures in Traditional Computing 10 Option 1: Make a New Service 10 Option 2: Add It to the Existing Service 11 Pros and Cons of Each Option 11 The Team Scenario, Continued 13 Conflicting Pressures 13 Event-Driven Communication Structures 13 Events Are the Basis of Communication 14 Event Streams Provide the Single Source of Truth 14 Consumers Perform Their Own Modeling and Querying 14 Data Communication Is Improved Across the Organization 15 Accessible Data Supports Business Communication Changes 15 Asynchronous Event-Driven Microservices 15 Example Team Using Event-Driven Microservices 16 Synchronous Microservices 17 iii
Page 6
Drawbacks of Synchronous Microservices 17 Benefits of Synchronous Microservices 19 Summary 20 2. Event-Driven Microservice Fundamentals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Building Topologies 21 Microservice Topology 21 Business Topology 22 The Contents of an Event 23 The Structure of an Event 23 Unkeyed Event 24 Entity Event 24 Keyed Event 24 Materializing State from Entity Events 25 Event Data Definitions and Schemas 27 Microservice Single Writer Principle 28 Powering Microservices with the Event Broker 28 Event Storage and Serving 29 Additional Factors to Consider 30 Event Brokers Versus Message Brokers 31 Consuming from the Immutable Log 32 Providing a Single Source of Truth 34 Managing Microservices at Scale 34 Putting Microservices into Containers 35 Putting Microservices into Virtual Machines 35 Managing Containers and Virtual Machines 35 Paying the Microservice Tax 36 Summary 37 3. Communication and Data Contracts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Event-Driven Data Contracts 39 Using Explicit Schemas as Contracts 40 Schema Definition Comments 41 Full-Featured Schema Evolution 41 Code Generator Support 42 Breaking Schema Changes 43 Selecting an Event Format 45 Designing Events 46 Tell the Truth, the Whole Truth, and Nothing but the Truth 46 Use a Singular Event Definition per Stream 46 Use the Narrowest Data Types 47 iv | Table of Contents
Page 7
Keep Events Single-Purpose 47 Minimize the Size of Events 51 Involve Prospective Consumers in the Event Design 51 Avoid Events as Semaphores or Signals 51 Summary 52 4. Integrating Event-Driven Architectures with Existing Systems. . . . . . . . . . . . . . . . . . . . 53 What Is Data Liberation? 54 Compromises for Data Liberation 55 Converting Liberated Data to Events 57 Data Liberation Patterns 57 Data Liberation Frameworks 58 Liberating Data by Query 58 Bulk Loading 59 Incremental Timestamp Loading 59 Autoincrementing ID Loading 59 Custom Querying 59 Incremental Updating 59 Benefits of Query-Based Updating 60 Drawbacks of Query-Based Updating 61 Liberating Data Using Change-Data Capture Logs 61 Benefits of Using Data Store Logs 63 Drawbacks of Using Data Base Logs 63 Liberating Data Using Outbox Tables 64 Performance Considerations 65 Isolating Internal Data Models 65 Ensuring Schema Compatibility 67 Capturing Change-Data Using Triggers 70 Making Data Definition Changes to Data Sets Under Capture 74 Handling After-the-Fact Data Definition Changes for the Query and CDC Log Patterns 75 Handling Data Definition Changes for Change-Data Table Capture Patterns 75 Sinking Event Data to Data Stores 75 The Impacts of Sinking and Sourcing on a Business 76 Summary 78 5. Event-Driven Processing Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Composing Stateless Topologies 80 Transformations 80 Branching and Merging Streams 81 Repartitioning Event Streams 81 Table of Contents | v
Page 8
Example: Repartitioning an Event Stream 82 Copartitioning Event Streams 83 Example: Copartitioning an Event Stream 83 Assigning Partitions to a Consumer Instance 84 Assigning Partitions with the Partition Assignor 84 Assigning Copartitioned Partitions 85 Partition Assignment Strategies 85 Recovering from Stateless Processing Instance Failures 87 Summary 87 6. Deterministic Stream Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Determinism with Event-Driven Workflows 90 Timestamps 90 Synchronizing Distributed Timestamps 92 Processing with Timestamped Events 92 Event Scheduling and Deterministic Processing 93 Custom Event Schedulers 94 Processing Based on Event Time, Processing Time, and Ingestion Time 94 Timestamp Extraction by the Consumer 95 Request-Response Calls to External Systems 95 Watermarks 95 Watermarks in Parallel Processing 96 Stream Time 97 Stream Time in Parallel Processing 98 Out-of-Order and Late-Arriving Events 99 Late Events with Watermarks and Stream Time 101 Causes and Impacts of Out-of-Order Events 101 Time-Sensitive Functions and Windowing 103 Handling Late Events 105 Reprocessing Versus Processing in Near-Real Time 106 Intermittent Failures and Late Events 107 Producer/Event Broker Connectivity Issues 108 Summary and Further Reading 109 7. Stateful Streaming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 State Stores and Materializing State from an Event Stream 111 Recording State to a Changelog Event Stream 112 Materializing State to an Internal State Store 113 Materializing Global State 114 Advantages of Using Internal State 114 Disadvantages of Using Internal State 116 vi | Table of Contents
Page 9
Scaling and Recovery of Internal State 116 Materializing State to an External State Store 120 Advantages of External State 120 Drawbacks of External State 121 Scaling and Recovery with External State Stores 122 Rebuilding Versus Migrating State Stores 124 Rebuilding 124 Migrating 124 Transactions and Effectively Once Processing 125 Example: Stock Accounting Service 126 Effectively Once Processing with Client-Broker Transactions 127 Effectively Once Processing Without Client-Broker Transactions 128 Summary 133 8. Building Workflows with Microservices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 The Choreography Pattern 136 A Simple Event-Driven Choreography Example 137 Creating and Modifying a Choreographed Workflow 138 Monitoring a Choreographed Workflow 139 The Orchestration Pattern 139 A Simple Event-Driven Orchestration Example 141 A Simple Direct-Call Orchestration Example 142 Comparing Direct-Call and Event-Driven Orchestration 142 Creating and Modifying an Orchestration Workflow 143 Monitoring the Orchestration Workflow 144 Distributed Transactions 144 Choreographed Transactions: The Saga Pattern 145 Orchestrated Transactions 146 Compensation Workflows 149 Summary 149 9. Microservices Using Function-as-a-Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Designing Function-Based Solutions as Microservices 151 Ensure Strict Membership to a Bounded Context 151 Commit Offsets Only After Processing Has Completed 152 Less Is More 153 Choosing a FaaS Provider 153 Building Microservices Out of Functions 153 Cold Start and Warm Starts 155 Starting Functions with Triggers 155 Triggering Based on New Events: The Event-Stream Listener 155 Table of Contents | vii
Page 10
Triggering Based on Consumer Group Lag 157 Triggering on a Schedule 158 Triggering Using Webhooks 159 Triggering on Resource Events 159 Performing Business Work with Functions 159 Maintaining State 160 Functions Calling Other Functions 160 Event-Driven Communication Pattern 161 Direct-Call Pattern 162 Termination and Shutdown 165 Tuning Your Functions 165 Allocating Sufficient Resources 165 Batch Event-Processing Parameters 166 Scaling Your FaaS Solutions 166 Summary 167 10. Basic Producer and Consumer Microservices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Where Do BPCs Work Well? 170 Integration with Existing and Legacy Systems 170 Stateful Business Logic That Isn’t Reliant Upon Event Order 171 When the Data Layer Does Much of the Work 172 Independent Scaling of the Processing and Data Layer 173 Hybrid BPC Applications with External Stream Processing 174 Example: Using an External Stream-Processing Framework to Join Event Streams 174 Summary 176 11. Heavyweight Framework Microservices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 A Brief History of Heavyweight Frameworks 178 The Inner Workings of Heavyweight Frameworks 179 Benefits and Limitations 181 Cluster Setup Options and Execution Modes 183 Use a Hosted Service 183 Build Your Own Full Cluster 183 Create Clusters with CMS Integration 184 Application Submission Modes 186 Driver Mode 186 Cluster Mode 186 Handling State and Using Checkpoints 186 Scaling Applications and Handling Event Stream Partitions 188 Scaling an Application While It Is Running 189 viii | Table of Contents
Page 11
Scaling an Application by Restarting It 191 Autoscaling Applications 192 Recovering from Failures 192 Multitenancy Considerations 192 Languages and Syntax 193 Choosing a Framework 193 Example: Session Windowing of Clicks and Views 194 Summary 197 12. Lightweight Framework Microservices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 Benefits and Limitations 199 Lightweight Processing 200 Handling State and Using Changelogs 201 Scaling Applications and Recovering from Failures 201 Event Shuffling 202 State Assignment 202 State Replication and Hot Replicas 203 Choosing a Lightweight Framework 203 Apache Kafka Streams 203 Apache Samza: Embedded Mode 204 Languages and Syntax 204 Stream-Table-Table Join: Enrichment Pattern 205 Summary 209 13. Integrating Event-Driven and Request-Response Microservices. . . . . . . . . . . . . . . . . . 211 Handling External Events 211 Autonomously Generated Events 212 Reactively Generated Events 212 Handling Autonomously Generated Analytical Events 213 Integrating with Third-Party Request-Response APIs 214 Processing and Serving Stateful Data 216 Serving Real-Time Requests with Internal State Stores 217 Serving Real-Time Requests with External State Stores 220 Handling Requests Within an Event-Driven Workflow 223 Processing Events for User Interfaces 224 Micro-Frontends in Request-Response Applications 231 The Benefits of Microfrontends 232 Composition-Based Microservices 232 Easy Alignment to Business Requirements 232 Drawbacks of Microfrontends 233 Potentially Inconsistent UI Elements and Styling 233 Table of Contents | ix
Page 12
Varying Microfrontend Performance 233 Example: Experience Search and Review Application 234 Summary 237 14. Supportive Tooling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 Microservice-to-Team Assignment System 239 Event Stream Creation and Modification 240 Event Stream Metadata Tagging 240 Quotas 241 Schema Registry 241 Schema Creation and Modification Notifications 243 Offset Management 243 Permissions and Access Control Lists for Event Streams 244 State Management and Application Reset 245 Consumer Offset Lag Monitoring 246 Streamlined Microservice Creation Process 247 Container Management Controls 247 Cluster Creation and Management 248 Programmatic Bringup of Event Brokers 248 Programmatic Bringup of Compute Resources 248 Cross-Cluster Event Data Replication 249 Programmatic Bringup of Tooling 249 Dependency Tracking and Topology Visualization 250 Topology Example 251 Summary 254 15. Testing Event-Driven Microservices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 General Testing Principles 255 Unit-Testing Topology Functions 256 Stateless Functions 256 Stateful Functions 256 Testing the Topology 257 Testing Schema Evolution and Compatibility 258 Integration Testing of Event-Driven Microservices 258 Local Integration Testing 259 Create a Temporary Environment Within the Runtime of Your Test Code 261 Create a Temporary Environment External to Your Test Code 262 Integrate Hosted Services Using Mocking and Simulator Options 263 Integrate Remote Services That Have No Local Options 264 Full Remote Integration Testing 265 Programmatically Create a Temporary Integration Testing Environment 265 x | Table of Contents
Page 13
Testing Using a Shared Environment 268 Testing Using the Production Environment 269 Choosing Your Full-Remote Integration Testing Strategy 270 Summary 270 16. Deploying Event-Driven Microservices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 Principles of Microservice Deployment 273 Architectural Components of Microservice Deployment 274 Continuous Integration, Delivery, and Deployment Systems 275 Container Management Systems and Commodity Hardware 276 The Basic Full-Stop Deployment Pattern 276 The Rolling Update Pattern 278 The Breaking Schema Change Pattern 279 Eventual Migration via Two Event Streams 280 Synchronized Migration to the New Event Stream 281 The Blue-Green Deployment Pattern 282 Summary 283 17. Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 Communication Layers 285 Business Domains and Bounded Contexts 286 Shareable Tools and Infrastructure 286 Schematized Events 287 Data Liberation and the Single Source of Truth 287 Microservices 288 Microservice Implementation Options 288 Testing 289 Deploying 289 Final Words 290 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Table of Contents | xi
Page 14
(This page has no text content)
Page 15
Preface I wrote this book to be the book that I wish I’d had when I started out on my journey into the world of event-driven microservices. This book is a culmination of my own personal experiences, discussions with others, and the countless blogs, books, posts, talks, conferences, and documentation related to one part or another of the event- driven microservice world. I found that many of the works I read mentioned event- driven architectures either only in passing or with insufficient depth. Some covered only a specific aspect of the architecture and, while helpful, provided only a small piece of the puzzle. Other works proved to be reductive and dismissive, asserting that event-driven systems are really only useful for one system to send an asynchronous message directly to another as a replacement for synchronous request-response sys‐ tems. As this book details, there is far more to event-driven architectures than this. The tools that we use shape and influence our inventions significantly. Event-driven microservice architectures are made possible by a whole host of technologies that have only recently become readily accessible. Distributed, fault-tolerant, high- capacity, and high-speed event brokers underpin the architectures and design pat‐ terns in this book. These technological solutions are based on the convergence of big data with the need for near-real-time event processing. Microservices are facilitated by the ease of containerization and the requisitioning of compute resources, allowing for simplified hosting, scaling, and management of hundreds of thousands of micro‐ services. The technologies that support event-driven microservices have a significant impact on how we think about and solve problems, as well as on how our businesses and organizations are structured. Event-driven microservices change how a business works, how problems can be solved, and how teams, people, and business units com‐ municate. These tools give you a truly new way of doing things that has not been pos‐ sible until only recently. xiii
Page 16
Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width Used for program listings, as well as within paragraphs to refer to program ele‐ ments such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold Shows commands or other text that should be typed literally by the user. Constant width italic Shows text that should be replaced with user-supplied values or by values deter‐ mined by context. This element signifies a tip or suggestion. This element signifies a general note. This element indicates a warning or caution. O’Reilly Online Learning For more than 40 years, O’Reilly Media has provided technol‐ ogy and business training, knowledge, and insight to help companies succeed. xiv | Preface
Page 17
Our unique network of experts and innovators share their knowledge and expertise through books, articles, and our online learning platform. O’Reilly’s online learning platform gives you on-demand access to live training courses, in-depth learning paths, interactive coding environments, and a vast collection of text and video from O’Reilly and 200+ other publishers. For more information, visit http://oreilly.com. How to Contact Us Please address comments and questions concerning this book to the publisher: O’Reilly Media, Inc. 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938 (in the United States or Canada) 707-829-0515 (international or local) 707-829-0104 (fax) We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at https://oreil.ly/building-event-driven- microservices. Email bookquestions@oreilly.com to comment or ask technical questions about this book. For news and information about our books and courses, visit http://oreilly.com. Find us on Facebook: http://facebook.com/oreilly Follow us on Twitter: http://twitter.com/oreillymedia Watch us on YouTube: http://youtube.com/oreillymedia Acknowledgments I’d like to express my respect and gratitude for the people at Confluent, who, along with inventing Apache Kafka, are some of the first people who particularly “get it” when it comes to event-driven architectures. I have been fortunate enough to have one of their members, Ben Stopford (lead technologist, Office of the CTO), provide ample and valuable feedback. Scott Morrison, CTO of PHEMI Systems, has also pro‐ vided me with valuable insights, feedback, and recommendations. I offer my thanks and gratitude to both Scott and Ben for helping make this book what it is today. As primary proofreaders and technical experts, they have helped me refine ideas, chal‐ lenged me to improve the content quality, prevented me from promoting incorrect information, and helped me tell the story of event-driven architectures. Preface | xv
Page 18
I would also like to extend my thanks to my friends Justin Tokarchuk, Gary Graham, and Nick Green, who proofread and edited a number of my drafts. Along with Scott and Ben, they helped me to identify the most significant weak points in my narrative, suggested ways to improve them, and provided their insights and personal experience in relation to the material. My thanks also goes out to the folks at O’Reilly for helping me in innumerable ways. I have worked with a number of excellent people during this experience, but in partic‐ ular I would like to thank my editor, Corbin Collins, for supporting me through some difficult times and helping keep me on track. He has been a great collaborator during this endeavor, and I appreciate the efforts he has put into supporting me. Rachel Monaghan, my copyeditor, reminded me of my high school days, when my essays would be returned colored with red highlights. I am extremely grateful for her sharp eye and knowledge of the English language—she helped make this book far easier to read and understand. Thank you, Rachel. Christopher Faucher has been very patient with me, providing me with excellent feedback and allowing me to make a number of nontrivial, last-minute changes to the book without blinking an eye. Thank you, Chris. Mike Loukides, VP of Content Strategy, was one of my first contacts at O’Reilly. When I approached him with my exceptionally verbose and lengthy proposal, he patiently worked with me to refocus it and refine it into the basis of the book before you today. I am grateful that he took the time to work with me and eventually move forward with this work. I have tried my best to heed his caution to avoid producing a tome that rivals the dictionary in length. To my mother and father, I thank you for giving me appreciation for the written word. I am grateful for their love and support. My father introduced me to Marshall McLuhan, and though I have largely failed to read most of his works, I have gained an immense appreciation for his evaluation on how the medium affects the message. This has transformed the way that I view and evaluate system architectures. Finally, thanks to everyone else who contributed in some way large or small to sup‐ porting me and this work. There are so many people who have contributed in their own way—through conversations, blog posts, presentations, open source code, anec‐ dotes, personal experiences, stories, and impromptu rants. Thank you, each and every one of you. It has been both a pleasure and a frustration to work on this book. There have been many times where I cursed myself for starting it, but thankfully there were many more times that I was glad I did. I hope that this book helps you, dear reader, in some way to learn and grow. xvi | Preface
Page 19
CHAPTER 1 Why Event-Driven Microservices The medium is the message. —Marshall McLuhan McLuhan argues that it is not the content of media, but rather engagement with its medium, that impacts humankind and introduces fundamental changes to society. Newspapers, radio, television, the internet, instant messaging, and social media have all changed human interaction and social structures thanks to our collective engagement. The same is true with computer system architectures. You need only look at the his‐ tory of computing inventions to see how network communications, relational data‐ bases, big-data developments, and cloud computing have significantly altered how architectures are built and how work is performed. Each of these inventions changed not only the way that technology was used within various software projects, but also the way that organizations, teams, and people communicated with one another. From centralized mainframes to distributed mobile applications, each new medium has fundamentally changed people’s relationship with computing. The medium of the asynchronously produced and consumed event has been funda‐ mentally shifted by modern technology. These events can now be persisted indefi‐ nitely, at extremely large scale, and be consumed by any service as many times as necessary. Compute resources can be easily acquired and released on-demand, ena‐ bling the easy creation and management of microservices. Microservices can store and manage their data according to their own needs, and do so at a scale that was previously limited to batch-based big-data solutions. These improvements to the humble and simple event-driven medium have far-reaching impacts that not only change computer architectures, but also completely reshape how teams, people, and organizations create systems and businesses. 1
Page 20
What Are Event-Driven Microservices? Microservices and microservice-style architectures have existed for many years, in many different forms, under many different names. Service-oriented architectures (SOAs) are often composed of multiple microservices synchronously communicating directly with one another. Message-passing architectures use consumable events to asynchronously communicate with one another. Event-based communication is cer‐ tainly not new, but the need for handling big data sets, at scale and in real time, is new and necessitates a change from the old architectural styles. In a modern event-driven microservices architecture, systems communicate by issu‐ ing and consuming events. These events are not destroyed upon consumption as in message-passing systems, but instead remain readily available for other consumers to read as they require. This is an important distinction, as it allows for the truly power‐ ful patterns covered in this book. The services themselves are small and purpose-built, created to help fulfill the neces‐ sary business goals of the organization. A typical definition of “small” is something that takes no more than two weeks to write. By another definition, the service should be able to (conceptually) fit within one’s own head. These services consume events from input event streams; apply their specific business logic; and may emit their own output events, provide data for request-response access, communicate with a third- party API, or perform other required actions. As this book will detail, these services can be stateful or stateless, complex or simple; and they might be implemented as long-running, standalone applications or executed as a function using Functions-as- a-Service. This combination of event streams and microservices forms an interconnected graph of activity across a business organization. Traditional computer architectures, com‐ posed of monoliths and intermonolith communications, have a similar graph struc‐ ture. Both of these graphs are shown in Figure 1-1. 2 | Chapter 1: Why Event-Driven Microservices
The above is a preview of the first 20 pages. Register to read the complete e-book.

Support Author

0.00
Total Amount (¥)
0
Donation Count
Please enter an amount Minimum ¥1

You will be redirected to Alipay to complete payment, then return here.

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List