Microservices with Go: Building scalable and reliable microservices with Go
- Length: 328 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-11-25
- ISBN-10: 1804617008
- ISBN-13: 9781804617007
- Sales Rank: #0 (See Top 100 Books)
Build, scale, and maintain microservices in Golang with ease.
Key Features
- Create and organize well-structured Go microservices
- Learn industry best practices and gain insights into Go microservice development tools, patterns, and solutions
- Cover hands-on Golang examples in each chapter
Book Description
This book covers the key benefits and common issues of microservices, helping you understand the problems microservice architecture helps to solve, the issues it usually introduces, and the ways to tackle them.
You’ll start by learning about the importance of using the right principles and standards in order to achieve the key benefits of microservice architecture. The following chapters will explain why the Go programming language is one of the most popular languages for microservice development and lay down the foundations for the next chapters of the book. You’ll explore the foundational aspects of Go microservice development including service scaffolding, service discovery, data serialization, synchronous and asynchronous communication, deployment, and testing. After covering the development aspects, you’ll progress to maintenance and reliability topics. The last part focuses on more advanced topics of Go microservice development including system reliability, observability, maintainability, and scalability. In this part, you’ll dive into the best practices and examples which illustrate how to apply the key ideas to existing applications, using the services scaffolded in the previous part as examples.
By the end of this book, you’ll have gained hands-on experience with everything you need to develop scalable, reliable and performant microservices using Go.
What you will learn
- Get familiar with the industry’s best practices and solutions in microservice development
- Understand service discovery in the microservices environment
- Explore reliability and observability principles
- Discover best practices for asynchronous communication
- Focus on how to write high-quality unit and integration tests in Go applications
- Understand how to profile Go microservices
Who this book is for
This book is for all types of developers, from people interested in learning how to write microservices in Go to seasoned professionals who want to take the next step in mastering the art of writing scalable and reliable microservice-based systems. A basic understanding of Go will come in handy.
Microservices with Go Contributors About the author About the reviewer Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Share Your Thoughts Download a free PDF copy of this book Part 1: Introduction Chapter 1: Introduction to Microservices What is a microservice? Motivation to use microservices Pros and cons of microservices Benefits of microservices Common issues of microservices When to use microservice architecture Role of Go in microservice development Summary Further reading Part 2: Foundation Chapter 2: Scaffolding a Go Microservice Technical requirements Go basics Core principles Writing idiomatic Go code Interfaces Tests Context Project structure Private packages Public packages Executable packages Other commonly used directories Common files Best practices Scaffolding an example application Movie application Application code structure Movie metadata service Movie service Summary Further reading Chapter 3: Service Discovery Technical requirements Service discovery overview Registry Service discovery models Service health monitoring Service discovery solutions HashiCorp Consul Kubernetes Adopting service discovery Preparing the application Implementing the discovery logic Using the discovery logic Summary Further reading Chapter 4: Serialization Technical requirements The basics of serialization Popular serialization formats Using Protocol Buffers Best practices for serialization Summary Further reading Chapter 5: Synchronous Communication Technical requirements Introduction to synchronous communication Go RPC frameworks and libraries Defining a service API using Protocol Buffers Implementing gateways and clients Metadata service Rating service Movie service Summary Further reading Chapter 6: Asynchronous Communication Technical requirements Asynchronous communication basics Benefits and challenges of asynchronous communication Techniques and patterns of asynchronous communication Using Apache Kafka for messaging Adopting Kafka for our microservices Asynchronous communication best practices Versioning Leveraging partitioning Summary Further reading Chapter 7: Storing Service Data Technical requirements Introduction to databases Using MySQL to store our service data Summary Further reading Chapter 8: Deployment with Kubernetes Technical requirements Preparing application code for deployments Deployment basics Application configuration Deploying via Kubernetes Introduction to Kubernetes Setting up our microservices for Kubernetes deployments Deployment best practices Automated rollbacks Canary deployments Replace with Continuous Deployment (CD) Summary Further reading Chapter 9: Unit and Integration Testing Technical requirements Go testing overview Unit tests Mocking Implementing unit tests Integration tests Testing best practices Using helpful messages Avoiding the use of Fatal in your logs Making a comparison using a cmp library Summary Further reading Part 3: Maintenance Chapter 10: Reliability Overview Technical requirements Reliability basics Achieving reliability through automation Communication error handling Graceful shutdown Achieving reliability through development processes and culture On-call process Incident management Reliability drills Summary Further reading Chapter 11: Collecting Service Telemetry Data Technical requirements Telemetry overview Collecting service logs Choosing the logging library Using logging features Storing microservice logs Logging best practices Collecting service metrics Storing metrics Popular Go metrics libraries Emitting service metrics Metrics best practices Tracing Tracing tools Collecting tracing data with the OpenTelemetry SDK Summary Further reading Chapter 12: Setting Up Service Alerting Technical requirements Alerting basics Alerting use cases Introduction to Prometheus Setting up Prometheus alerting for our microservices Alerting best practices Summary Further reading Chapter 13: Advanced Topics Technical requirements Profiling Go services Creating microservice dashboards Frameworks Storing microservice ownership data Securing microservice communication with JWT JWT basics Implementing authentication and authorization with JWTs Summary Further reading Index Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts Download a free PDF copy of this book
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Microservices with Go: Building scalable and reliable microservices with Go
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.