Microservices architecture uses an assembly of fine-grained services to deliver functionality. The goal of this architectural style is to innovate by reducing the dependencies between teams, which results in faster code to production. Serverless architecture code is an execution model where server-side logic is run in stateless, event-triggered, ephemeral compute containers that are fully managed by a third party. It is associated with less management overhead (as there are no servers to maintain) and is cheaper to operate since you only pay for what you use. While there are similarities and dissimilarities with both architectural styles, both require an application to be composed of a collection of loosely coupled components, which implement business capabilities. Thus, it is possible to implement microservices architecture as a serverless application.
Nikhil Barthwal elaborates, covering the pros and cons, details of various deployment patterns, and best practices. You’ll learn how to implement distributed sagas as a protocol for coordinating request among multiple functions, how code can be structured in both monorepo and multirepo, and how to leverage Apache Thrift and Google Protocol buffers to manage contracts between functions representing services. You’ll also discover how to use a unique ID attached to every message to gain more visibility during the runtime and prevent the problem of getting stuck in an infinite loop as well as why you need a rollback mechanism (which is needed for sagas anyway) and why you should embrace eventual consistency when designing fault-tolerant business processes.
Nikhil Barthwal is a senior software engineer and a startup mentor at Grand Central Tech. Over his career, he’s worked with both big companies and smaller startups. He’s particularly fond of using functional programming languages for better productivity. Outside of work, he speaks at local meetups and international conferences on topics related to distributed systems and programming languages.
©2018, O’Reilly UK Ltd • (800) 889-8969 or (707) 827-7019 • Monday-Friday 7:30am-5pm PT • All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners. • email@example.com