Microservices vs. Service- Oriented Architecture Mark Richards Microservices vs. Service-Oriented Architecture by Mark Richards Copyright © 2016 O’Reilly Media. 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://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or [email protected]. Editors: Nan Barber, Rachel Roumeliotis Interior Designer: David Futato Production Editor: Nicholas Adams Cover Designer: Randy Comer Copyeditor: Eileen Cohen Illustrator: Rebecca Demarest Proofreader: Nicholas Adams November 2015: First Edition Revision History for the First Edition 2015-11-17: First Release 2015-04-22: Second Release The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Microservices vs. Service-Oriented Architectures and related trade dress are trademarks of O’Reilly Media, Inc. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors 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 sub‐ ject 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. 978-1-491-94161-4 [LSI] Table of Contents Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi 1. The World of Service-Based Architectures. . . . . . . . . . . . . . . . . . . . . . . 1 Service Contracts 2 Service Availability 5 Security 7 Transactions 8 Too Much Complexity? 9 2. Comparing Service Characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Service Taxonomy 11 Service Ownership and Coordination 14 Service Granularity 17 Granularity and Pattern Selection 19 3. Comparing Architecture Characteristics. . . . . . . . . . . . . . . . . . . . . . . . 21 Component Sharing 22 Service Orchestration and Choreography 24 Middleware vs. API Layer 30 Accessing Remote Services 33 4. Comparing Architecture Capabilities. . . . . . . . . . . . . . . . . . . . . . . . . . 35 Application Scope 35 Heterogeneous Interoperability 36 vii Contract Decoupling 39 5. Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 viii | Table of Contents Foreword One of the fascinating aspects of software engineering is how great concepts endure, but their execution and application are regularly reinvented using the tools and practices of the day. The rise of microservices patterns and practices is a great example of this pro‐ cess. Skeptics may dismiss microservices as little more than the service- oriented architecture (SOA) practices of the 2000s, reheated. The reality is that microservices are an example of convergent evolution, emerging from modern development, testing, and deployment tech‐ niques and shaped by the democratizing influence of open source. The resulting incarnation of SOA is transforming our industry. What’s the nature of this transformation? Early adopters report that when used with an agile and autonomous approach to engineering structures and a DevOps approach to delivery, the microservices approach enables a much quicker cadence of application develop‐ ment. In turn, software developers welcome this, having learned their trade in the fast-moving, app-driven world of services and applications. The net result is faster innovation, and a potential competitive advantage for Internet-facing organizations that embrace these practices. The power of microservices comes from their non-prescriptive nature. There is no formal, slow-moving, industry-driven specifica‐ tion; rather, the microservices approach has emerged as a pattern of development that has been practiced and refined by pioneers. Born in the modern Web, microservices are interconnected using a thin layer of simple APIs and the lingua franca of HTTP. At NGINX, we are incredibly proud of our role in accelerating, securing, scaling, and delivering microservices-based applications. As the HTTP “connective tissue” of modern applications, NGINX serves as both the stable entry point to a microservices-based application, and the traffic manager for communication between the microservices themselves. The lack of a prescriptive industry specification is sure to raise many, many questions—especially if you have experience with pre‐ vious SOA practices. Microservices have at times been billed as “SOA done right,” but is that really the case? And what exactly did earlier practices do wrong that microservices are getting right? In this report, Mark Richards provides a thoughtful breakdown of the two approaches and discusses where one approach might be prefer‐ red over the other. By the end of this report, you’ll have not only a greater understanding of these two architectural patterns, but also of application development as a whole. We hope you enjoy this report. —Owen Garrett, Head of Products, NGINX, Inc.