{"id":482,"date":"2021-12-21T15:04:29","date_gmt":"2021-12-21T20:04:29","guid":{"rendered":"https:\/\/freedville.com\/blog\/?p=482"},"modified":"2021-12-21T15:04:31","modified_gmt":"2021-12-21T20:04:31","slug":"book-review-microservices-patterns","status":"publish","type":"post","link":"https:\/\/freedville.com\/blog\/2021\/12\/21\/book-review-microservices-patterns\/","title":{"rendered":"Book Review: Microservices Patterns"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"427\" src=\"https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/james-wainscoat-b7MZ6iGIoSI-unsplash-1.jpg\" alt=\"A flock of birds moving in one direction.\" class=\"wp-image-487\" srcset=\"https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/james-wainscoat-b7MZ6iGIoSI-unsplash-1.jpg 640w, https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/james-wainscoat-b7MZ6iGIoSI-unsplash-1-300x200.jpg 300w, https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/james-wainscoat-b7MZ6iGIoSI-unsplash-1-175x117.jpg 175w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><figcaption><meta charset=\"utf-8\">Microservices are independent, but still work together. Photo by <a href=\"https:\/\/unsplash.com\/@tumbao1949?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\">James Wainscoat<\/a> on <a href=\"https:\/\/unsplash.com\/s\/photos\/flock-of-bird?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<p>I\u2019ve heard many good things about microservices but have had only limited opportunities to try them out.\u00a0 I wanted to learn more and <a href=\"https:\/\/www.manning.com\/books\/microservices-patterns\">Microservices Patterns by Chris Richardson<\/a> was the perfect opportunity.<\/p>\n\n\n\n<p>I know there are <a href=\"https:\/\/en.wikipedia.org\/wiki\/No_Silver_Bullet\">no silver bullets<\/a> in software development and Richardson reminds us immediately.\u00a0 Architecture is all about tradeoffs and microservices architecture is no different.\u00a0 The best part of this book is that every pattern is presented with the benefits and drawbacks of that pattern.<\/p>\n\n\n\n<p>In fact Richardson suggests that you start off with a monolithic approach \u2013 not microservices.&nbsp; For most applications, this is all you need.&nbsp; This is a core point of microservices \u2013 you may not need it \u2013 and its one I don\u2019t see enough practitioners pay attention to.&nbsp; However I\u2019ve wondered if it\u2019s worth taking that idea to the extreme \u2013 that you never need microservices.&nbsp; This book convinced me otherwise.<\/p>\n\n\n\n<p>There\u2019s not a clear point when microservices is \u201cbetter\u201d to use than a monolithic architecture, but this book outlines the signs that it may be time:<\/p>\n\n\n\n<ul><li>Your application keeps growing in code and developers<\/li><li>Complexity increases to where no one person can keep the application in their head any more<\/li><li>Development velocity slows down<\/li><li>Changes take a very long time to test because you don\u2019t know what parts of a test suite to run<\/li><li>You\u2019re feeling a \u201clock-in\u201d to old technology but a rewrite would take too long<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"427\" src=\"https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/markus-winkler-yNh7S4FqCOQ-unsplash.jpg\" alt=\"A pile of puzzle pieces.\" class=\"wp-image-486\" srcset=\"https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/markus-winkler-yNh7S4FqCOQ-unsplash.jpg 640w, https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/markus-winkler-yNh7S4FqCOQ-unsplash-300x200.jpg 300w, https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/markus-winkler-yNh7S4FqCOQ-unsplash-175x117.jpg 175w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><figcaption>It&#8217;s sometimes hard to see how all the pieces fit together! Anything that reduces your search space is worth considering.  Photo by <a href=\"https:\/\/unsplash.com\/@markuswinkler?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\">Markus Winkler<\/a> on <a href=\"https:\/\/unsplash.com\/s\/photos\/puzzle-pieces?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<p>Richardson convinced me \u2013 there are definitely cases where microservices make sense!\u00a0 At the very least, it seems inconceivable to run an internet-scale technology like Amazon without microservices.\u00a0 And since microservices sometimes make sense, I wanted to learn more about the situations where they help, and more importantly, why they help.<\/p>\n\n\n\n<p>The central premise is that smaller pieces, even if not \u201cmicro\u201d, give you more degrees of freedom.&nbsp; If an application has four major pieces, it\u2019s difficult to get all four pieces coordinated for lock-step deployments.&nbsp; It\u2019s much easier if any decision only affects one-fourth of the whole \u2013 whether that decision is an implementation detail, a testing detail, or a runtime detail.<\/p>\n\n\n\n<p>Still separation is never that pure and even if you focus on one component it can still affect the others.&nbsp; My concern with microservices is that it can be difficult to coordinate design, implementation, and test across services.&nbsp; Many people have noted that microservices moves complexity from the implementation code to the deployment runtime. &nbsp;I shudder at the thought of debugging a production issue that touches four different services.&nbsp; But after reading this book I realize that it would still be difficult to debug (and fix) an issue in a monolithic application if the issue had that many elements.<\/p>\n\n\n\n<p>Microservices doesn\u2019t claim to solve this cross-service issue.&nbsp; The implicit argument is that the cost of difficult cross-service issues is balanced by the other benefits from having smaller, independent services.&nbsp; I\u2019ve not worked on a system large enough to require this, but I can appreciate the argument.<\/p>\n\n\n\n<p>The biggest challenge in moving to microservices is changing the development mindset.\u00a0 You have to re-think how transactions are implemented.\u00a0 Rather than having atomic transactions with <a href=\"https:\/\/en.wikipedia.org\/wiki\/ACID\">ACID (Atomicity, Consistency, Reliability, and Durability)<\/a>, you have distributed sagas with <a href=\"https:\/\/stackoverflow.com\/questions\/3342497\/explanation-of-base-terminology\">BASE (BAsic Availability, Soft State, Eventual Consistency)<\/a>.\u00a0 This improves scalability and availability at the cost of thinking through how to deal with eventual consistency.<\/p>\n\n\n\n<p>The two biggest challenges I see in microservices are first designing the right service boundaries, and second understanding how to program with BASE instead of ACID.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"960\" src=\"https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/nasim-keshmiri-9P1DP6xKRvU-unsplash.jpg\" alt=\"An article of clothing showing several distinct thread patterns.\" class=\"wp-image-488\" srcset=\"https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/nasim-keshmiri-9P1DP6xKRvU-unsplash.jpg 640w, https:\/\/freedville.com\/blog\/wp-content\/uploads\/2021\/12\/nasim-keshmiri-9P1DP6xKRvU-unsplash-200x300.jpg 200w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><figcaption>Can you handle distributed data and distributed services, and tie them together into a coherent whole?  Photo by <a href=\"https:\/\/unsplash.com\/@nasimkeshmiri?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\">Nasim Keshmiri<\/a> on <a href=\"https:\/\/unsplash.com\/s\/photos\/crocheting?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<p>One thing I had not realized was that microservices may have to use data replication to reference data not in their service.&nbsp; The book uses an example including Order and Delivery microservices, where Delivery depends on Order.&nbsp; The Delivery service may end up replicating an Order table in its own datastore to support efficient queries, rather than using Order\u2019s API every time.&nbsp; Several chapters in the book describe messaging and data replication strategies that help with managing distributed state, while still allowing (mostly) independent services.<\/p>\n\n\n\n<p>Lastly, a microservices architecture adds a lot of concerns that need to be handled including distributed tracing, service discovery, partial failure modes, load balancing, and more.&nbsp; I came to appreciate this is why service meshes, like Istio, have emerged.&nbsp; Instead of heaping dozens of more responsibilities onto service developers, service meshes are introduced to pick up part of the load.<\/p>\n\n\n\n<p>Overall this was a very insightful book.&nbsp; Every solution is presented with benefits and drawbacks and this is the essence of architecture.&nbsp; I now understand many of the design points in my own IBM Cloud and other applications I\u2019ve worked with.&nbsp; Thanks Chris for a great book!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019ve heard many good things about microservices but have had only limited opportunities to try them out.\u00a0 I wanted to learn more and Microservices Patterns by Chris Richardson was the perfect opportunity. I know there&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts\/482"}],"collection":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/comments?post=482"}],"version-history":[{"count":3,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts\/482\/revisions"}],"predecessor-version":[{"id":489,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts\/482\/revisions\/489"}],"wp:attachment":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/media?parent=482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/categories?post=482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/tags?post=482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}