Book Image

Microservices with Go

By : Alexander Shuiskov
Book Image

Microservices with Go

By: Alexander Shuiskov

Overview of this book

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.
Table of Contents (19 chapters)
1
Part 1: Introduction
3
Part 2: Foundation
12
Part 3: Maintenance

What this book covers

Chapter 1, Introduction to Microservices, will cover the key benefits of and common issues with a microservice architecture, helping you to understand which problems microservices solve and which challenges they usually introduce. The chapter emphasizes the role of the Go programming language in microservice development and lays down the foundation for the rest of the book.

Chapter 2, Scaffolding a Go Microservice, will introduce the you to the main principles of the Go programming language and provide the most important recommendations for writing Go code. It will cover the process of setting up the right structure to organize the microservice code in Go and introduce the you to an example application consisting of three microservices. Finally, the chapter will illustrate how to scaffold the code for each of the example microservices. The example microservices implemented in this chapter are going to be used throughout the book, with each chapter adding new features to them.

Chapter 3, Service Discovery, will talk about the problem of service discovery and illustrates how different services can find each other in a microservice environment. It will cover the most popular service discovery tools and walk the you through the steps of adding service discovery logic to the example microservices from the previous chapter.

Chapter 4, Serialization, will bring us to the concept of data serialization, which is required for understanding upcoming chapters covering microservice communication. The you will be introduced to the Protocol Buffers data format, which is going to be used for encoding and decoding the data transferred between our example microservices. The chapter will provide examples of how to define serializable data types and generate code for them, and how to use the generated code in Go microservices.

Chapter 5, Synchronous Communication, will cover the topic of synchronous communication between microservices. It will illustrate how to define service APIs using the Protocol Buffers format and introduce the you to gRPC, a service communication framework. The chapter will wrap up with examples of how to implement microservice gateways and clients and perform remote calls between our microservices.

Chapter 6, Asynchronous Communication, will talk about asynchronous communication between microservices. It will introduce the you to a popular asynchronous communication tool, Apache Kafka, and provide examples of sending and receiving messages, using it for our example microservices. The chapter will wrap up with an overview of the best practices for using asynchronous communication in microservice environments.

Chapter 7, Storing Service Data, will cover the topic of persisting service data in databases. The you will learn about the common types of databases and the benefits they bring to software developers. The chapter will walk the you through the process of implementing the logic for storing service data in a MySQL database.

Chapter 8, Deployment with Kubernetes, will talk about service deployment and provide an overview of a popular deployment and orchestration platform, Kubernetes. The chapter will illustrate how to prepare service code for deployment and how to deploy it using Kubernetes. The chapter will include the best practices for deploying microservice applications.

Chapter 9, Unit and Integration Testing, will describe the common techniques of testing Go microservice code. It will cover the basics of Go unit and integration testing and demonstrate how to test the microservice code from the previous chapters. The chapter will wrap up with the industry’s best practices for writing and organizing tests.

Chapter 10, Reliability Overview, will introduce the you to the topic of system reliability and describe the core principles, instruments, and industry best practices for building reliable and highly available microservices. It will illustrate how to automate service responses to various types of failures, as well as how to establish the processes for keeping service reliability under control.

Chapter 11, Collecting Service Telemetry Data, will provide a detailed overview of modern instruments and solutions for collecting service telemetry data, such as logs, metrics, and traces. The chapter will provide lots of detailed examples of collecting all different types of telemetry data and list some of the best practices for working with them.

Chapter 12, Setting up Service Alerting, will illustrate how to set up automated incident detection and notification for microservices, using the telemetry data collected in the previous chapter. It will introduce the you to a popular alerting and monitoring tool, Prometheus, and show how to set up Prometheus alerts for our example microservices.

Chapter 13, Advanced Topics, will wrap up the last part of the book and cover some of the advanced topics in microservice development, such as profiling, dashboarding, frameworks, service ownership, and security. The chapter will include some examples of setting up secure communication between Go microservices using the JWT protocol.