Morgan Bruce Paulo A. Pereira M A N N I N G A microservice production environment Production Monitors g y d routin Connects ervabilit Observes n s Engineers a b k O or w et N Writes Manages Runtime Control pane Deployment pipeline Code management A microservice production environment has several components: a deployment target, a deployment pipeline, runtime management, networking features, and support for observability. In this book, we'll teach you about these components and how you can use them to build a stable, modern microservice application. Microservices in Action Microservices in Action MORGAN BRUCE PAULO A. PEREIRA MANNING Shelter ISland For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: [email protected] ©2019 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. ∞Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-f ree paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. Acquisitions editor: Michael Stephens 20 Baldwin Road Development editor: Karen Miller PO Box 761 Technical development editor: Karsten Strøbæk Shelter Island, NY 11964 Review editor: Aleksander Dragosavljevic´ Project editor: Anthony Calcara Copy editor: Carl Quesnel Proofreader: Keri Hales Technical proofreader: John Guthrie Typesetter: Happenstance Type-O-Rama Cover designer: Marija Tudor ISBN 9781617294457 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 — DP — 23 22 21 20 19 18 brief contents Part 1 The lay of the land ................................................. 1 1 ■ Designing and running microservices 3 2 ■ Microservices at SimpleBank 28 Part 2 Design .......................................................................49 3 ■ Architecture of a microservice application 51 4 ■ Designing new features 75 5 ■ Transactions and queries in microservices 105 6 ■ Designing reliable services 129 7 ■ Building a reusable microservice framework 159 Part 3 Deployment ............................................................185 8 ■ Deploying microservices 187 9 ■ Deployment with containers and schedulers 214 10 ■ Building a delivery pipeline for microservices 243 Part 4 Observability and ownership .............................267 11 ■ Building a monitoring system 269 12 ■ Using logs and traces to understand behavior 296 13 ■ Building microservice teams 325 v contents preface xv acknowledgments xvii about this book xix about the authors xxii about the cover illustration xxiii Part 1 The lay of the land ......................................1 1 Designing and running microservices 3 1.1 What is a microservice application? 4 Scaling through decomposition 6 ■ Key principles 7 ■ Who uses microservices? ■ Why are microservices a good choice? 12 1.2 What makes microservices challenging? 14 Design challenges ■ Operational challenges 17 1.3 Microservice development lifecycle 18 Designing microservices ■ Deploying microservices ■ Observing microservices 24 1.4 Responsible and operationally aware engineering culture 26 vii