SlideShare a Scribd company logo
Microservices in Go with Go kit
Shiju Varghese
https://medium.com/@shijuvar
DevConf.IN
August 02, 2019
Bengaluru
About Me
• Consulting Solutions Architect on Go and Distributed Systems

• Published Author: Web Development with Go and Go Recipes
• Awarded Microsoft MVP seven times

• Speaker at numerous conferences

• medium.com/@shijuvar | github.com/shijuvar | linkedin.com/in/shijuvar
Agenda
• Introduction to Microservices Architecture 

• Introduction to Go kit

• Building Microservices with Go kit
Microservices Architecture
Scale Cube : 3 Dimensions to Scale
Microservices is an architectural style for building
highly scalable applications, in which an application
decomposes into a set of services as functional
components.
Microservices Architecture is all about functional
decomposition.
• A modern, practical programming language
• Concurrent, Simple, Fast, Type-safe, Compiled very quickly
• A great language for Cloud-Native, Microservices
Go Programming Language
Go kit
Go kit
• A programming toolkit (collection of Go packages) for building
robust, reliable, maintainable microservices
• Solves common problems in distributed systems
• Bootstrap development towards Microservices
• Go kit design is well-suited for modern software design: both
microservices and elegant monoliths
Go kit Architecture
There are three major components in the Go kit based application
architecture:

• Transport layer: The transport domain 

• Endpoint layer: An RPC method

• Service layer: Business logic layer
Transports
• The transport domain is bound to concrete transports 

• Provide transports like HTTP, gRPC, NATS, AMQP, Thrift, etc

• A single microservice can support multiple transports
Endpoints
• An RPC method bound to a service method

• RPC as the primary messaging pattern

• Each endpoint exposes the service method to the outside world using
Transport layer 

type Endpoint func(ctx context.Context, request interface{}) (response
interface{}, err error)
Services
• Business logic modelled as interfaces

• Based on the Clean Architecture or the Hexagonal Architecture

• No knowledge about endpoint, concrete transports and encoding/
decoding
Clean Architecture
The central rule of The Clean Architecture is
the Dependency Rule, which says:
Source code dependencies can only point inwards.
In other words, the source code of each circle can
only access code in an inner circle but never any
code in an outer circle.
Flow of requests and responses
• Request flow: Transport layer -> Endpoint layer -> Service layer

• Response flow: Service layer -> Endpoint layer -> Transport layer
Demo: Building Services with Go kit
Middleware
• A strict separation of concerns through use of the decorator

• Wrap endpoints or services to add functionality, such as logging, rate
limiting and distributed tracing

• Two types of middlewares: Endpoint middleware and Service middleware
Endpoint Middleware
• An endpoint middleware is a function that takes an endpoint and returns
an endpoint.

type Middleware func(Endpoint) Endpoint
• Use endpoint middlewares for transport-domain concerns, like circuit
breaking and rate limiting.
Microservices in Go with Go kit
Service Middleware
• An service middleware is a function that takes a service and returns a
service.

type Middleware func(Service) Service
• Use service middlewares for business-domain concerns, like logging and
instrumentation.
Microservices in Go with Go kit
Demo: Wrapping Go kit services
with Middlewares
Design of Go kit services
1. Implements the core business logic by defining
an interface for service and providing a concrete
implementation.

2. Writes service middlewares to provide additional
functionality, like logging, analytics,
instrumentation — anything that needs
knowledge of business domain.

3. Go kit provides endpoint and transport domain
middlewares, for functionality like rate limiting,
circuit breaking, load balancing, and distributed
tracing — all of which are generally agnostic to
business domain.
Source Code
https://github.com/shijuvar/gokit-examples
Thanks
Shiju Varghese
gophermonk@gmail.com
https://medium.com/@shijuvar
https://github.com/shijuvar
https://linkedin.com/in/shijuvar
Go Programming Workshops: https://bit.ly/shijuv-go

More Related Content

PDF
Building High Performance APIs In Go Using gRPC And Protocol Buffers
PDF
Building Microservices with gRPC and NATS
PDF
Introduction to gRPC
PDF
Inter-Process Communication in Microservices using gRPC
PPTX
Introduction to microservices
PDF
gRPC Overview
PDF
gRPC with java
PDF
gRPC Design and Implementation
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building Microservices with gRPC and NATS
Introduction to gRPC
Inter-Process Communication in Microservices using gRPC
Introduction to microservices
gRPC Overview
gRPC with java
gRPC Design and Implementation

What's hot (20)

PPTX
Full stack development
PDF
Why Microservice
PDF
Introduction to GraphQL
PDF
Introduction to Kong API Gateway
PDF
gRPC and Microservices
PDF
Docker 101: Introduction to Docker
PDF
MoP(MQTT on Pulsar) - a Powerful Tool for Apache Pulsar in IoT - Pulsar Summi...
PPTX
Introduction to GraphQL
PPT
Docker introduction
PPT
presentation on Docker
PPTX
Introduction to microservices
PPTX
Rancher and Kubernetes Best Practices
PDF
Microservice architecture
PDF
KrakenD API Gateway
PPTX
NATS for Modern Messaging and Microservices
PPTX
Introduction to KSQL: Streaming SQL for Apache Kafka®
PPTX
Api gateway in microservices
PDF
Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...
PDF
Microservices Integration Patterns with Kafka
PDF
Apache Kafka Fundamentals for Architects, Admins and Developers
Full stack development
Why Microservice
Introduction to GraphQL
Introduction to Kong API Gateway
gRPC and Microservices
Docker 101: Introduction to Docker
MoP(MQTT on Pulsar) - a Powerful Tool for Apache Pulsar in IoT - Pulsar Summi...
Introduction to GraphQL
Docker introduction
presentation on Docker
Introduction to microservices
Rancher and Kubernetes Best Practices
Microservice architecture
KrakenD API Gateway
NATS for Modern Messaging and Microservices
Introduction to KSQL: Streaming SQL for Apache Kafka®
Api gateway in microservices
Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...
Microservices Integration Patterns with Kafka
Apache Kafka Fundamentals for Architects, Admins and Developers
Ad

Similar to Microservices in Go with Go kit (20)

PPTX
Application Centric Microservices from Redhat Summit 2015
PDF
Istio as an enabler for migrating to microservices (edition 2022)
PDF
Service Mesh Talk for CTO Forum
PDF
Ekon20 mORMot SOA Delphi Conference
PDF
Migrating to Microservices Patterns and Technologies (edition 2023)
PDF
Microdeployments for microservices dev ops nashville
PDF
Automating Applications with Habitat - Sydney Cloud Native Meetup
PPTX
Business and IT agility through DevOps and microservice architecture powered ...
PDF
Practical Microservice Architecture (edition 2022).pdf
PPTX
Designing Microservices
PPTX
Microservices-101
PPTX
Micro service session 1
PPTX
MICROSERVICES ARCHITECTURE unit -2.pptx
PDF
Newt global meetup microservices
PPTX
Continuous Integration
PPTX
Shopify - CNCF March 2025 Meetup - Presentation - 26-03-25.pptx
PDF
CV - Abhijit
PPTX
Rez gateway (RezOS) innovate the future
PPTX
Rez gateway - RezOS - innovate the future
PPTX
Agile methodology in cloud computing
Application Centric Microservices from Redhat Summit 2015
Istio as an enabler for migrating to microservices (edition 2022)
Service Mesh Talk for CTO Forum
Ekon20 mORMot SOA Delphi Conference
Migrating to Microservices Patterns and Technologies (edition 2023)
Microdeployments for microservices dev ops nashville
Automating Applications with Habitat - Sydney Cloud Native Meetup
Business and IT agility through DevOps and microservice architecture powered ...
Practical Microservice Architecture (edition 2022).pdf
Designing Microservices
Microservices-101
Micro service session 1
MICROSERVICES ARCHITECTURE unit -2.pptx
Newt global meetup microservices
Continuous Integration
Shopify - CNCF March 2025 Meetup - Presentation - 26-03-25.pptx
CV - Abhijit
Rez gateway (RezOS) innovate the future
Rez gateway - RezOS - innovate the future
Agile methodology in cloud computing
Ad

More from Shiju Varghese (20)

PDF
Building Modern Distributed Applications in Go with Service Weaver
PDF
NATS: A Cloud Native Messaging System
PDF
Event-Driven Microservices With NATS Streaming
PDF
Building Scalable Backends with Go
PDF
A Primer to Containerization & Microservices
PDF
Writing HTTP Middleware In Go
PDF
Building RESTful Services With Go and MongoDB
PDF
Docker and Kubernetes
PDF
Practicing Mindfulness
PPSX
Azure DocumentDB
PPSX
Azure Mobile Services .NET Backend
PDF
Windows Azure Mobile Services
PDF
JavaScript, Meet Cloud : Node.js on Windows Azure
PPSX
Introduction to Node js
PPSX
Windows Azure Cloud Services
PPSX
Windows Azure Webs Sites
PPS
Building Apps with Node.js
PPSX
Node on Windows Azure
PPTX
Introducing Razor - A new view engine for ASP.NET
PPTX
NoSQL Database in .NET Apps
Building Modern Distributed Applications in Go with Service Weaver
NATS: A Cloud Native Messaging System
Event-Driven Microservices With NATS Streaming
Building Scalable Backends with Go
A Primer to Containerization & Microservices
Writing HTTP Middleware In Go
Building RESTful Services With Go and MongoDB
Docker and Kubernetes
Practicing Mindfulness
Azure DocumentDB
Azure Mobile Services .NET Backend
Windows Azure Mobile Services
JavaScript, Meet Cloud : Node.js on Windows Azure
Introduction to Node js
Windows Azure Cloud Services
Windows Azure Webs Sites
Building Apps with Node.js
Node on Windows Azure
Introducing Razor - A new view engine for ASP.NET
NoSQL Database in .NET Apps

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Cloud computing and distributed systems.
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Encapsulation theory and applications.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Reach Out and Touch Someone: Haptics and Empathic Computing
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
MIND Revenue Release Quarter 2 2025 Press Release
Cloud computing and distributed systems.
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Encapsulation theory and applications.pdf
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Programs and apps: productivity, graphics, security and other tools
Advanced methodologies resolving dimensionality complications for autism neur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
NewMind AI Weekly Chronicles - August'25 Week I
20250228 LYD VKU AI Blended-Learning.pptx
Unlocking AI with Model Context Protocol (MCP)

Microservices in Go with Go kit

  • 1. Microservices in Go with Go kit Shiju Varghese https://medium.com/@shijuvar DevConf.IN August 02, 2019 Bengaluru
  • 2. About Me • Consulting Solutions Architect on Go and Distributed Systems • Published Author: Web Development with Go and Go Recipes • Awarded Microsoft MVP seven times • Speaker at numerous conferences • medium.com/@shijuvar | github.com/shijuvar | linkedin.com/in/shijuvar
  • 3. Agenda • Introduction to Microservices Architecture • Introduction to Go kit • Building Microservices with Go kit
  • 5. Scale Cube : 3 Dimensions to Scale
  • 6. Microservices is an architectural style for building highly scalable applications, in which an application decomposes into a set of services as functional components. Microservices Architecture is all about functional decomposition.
  • 7. • A modern, practical programming language • Concurrent, Simple, Fast, Type-safe, Compiled very quickly • A great language for Cloud-Native, Microservices Go Programming Language
  • 9. Go kit • A programming toolkit (collection of Go packages) for building robust, reliable, maintainable microservices • Solves common problems in distributed systems • Bootstrap development towards Microservices • Go kit design is well-suited for modern software design: both microservices and elegant monoliths
  • 10. Go kit Architecture There are three major components in the Go kit based application architecture: • Transport layer: The transport domain • Endpoint layer: An RPC method • Service layer: Business logic layer
  • 11. Transports • The transport domain is bound to concrete transports • Provide transports like HTTP, gRPC, NATS, AMQP, Thrift, etc • A single microservice can support multiple transports
  • 12. Endpoints • An RPC method bound to a service method • RPC as the primary messaging pattern • Each endpoint exposes the service method to the outside world using Transport layer type Endpoint func(ctx context.Context, request interface{}) (response interface{}, err error)
  • 13. Services • Business logic modelled as interfaces • Based on the Clean Architecture or the Hexagonal Architecture • No knowledge about endpoint, concrete transports and encoding/ decoding
  • 14. Clean Architecture The central rule of The Clean Architecture is the Dependency Rule, which says: Source code dependencies can only point inwards. In other words, the source code of each circle can only access code in an inner circle but never any code in an outer circle.
  • 15. Flow of requests and responses • Request flow: Transport layer -> Endpoint layer -> Service layer • Response flow: Service layer -> Endpoint layer -> Transport layer
  • 16. Demo: Building Services with Go kit
  • 17. Middleware • A strict separation of concerns through use of the decorator • Wrap endpoints or services to add functionality, such as logging, rate limiting and distributed tracing • Two types of middlewares: Endpoint middleware and Service middleware
  • 18. Endpoint Middleware • An endpoint middleware is a function that takes an endpoint and returns an endpoint. type Middleware func(Endpoint) Endpoint • Use endpoint middlewares for transport-domain concerns, like circuit breaking and rate limiting.
  • 20. Service Middleware • An service middleware is a function that takes a service and returns a service. type Middleware func(Service) Service • Use service middlewares for business-domain concerns, like logging and instrumentation.
  • 22. Demo: Wrapping Go kit services with Middlewares
  • 23. Design of Go kit services 1. Implements the core business logic by defining an interface for service and providing a concrete implementation. 2. Writes service middlewares to provide additional functionality, like logging, analytics, instrumentation — anything that needs knowledge of business domain. 3. Go kit provides endpoint and transport domain middlewares, for functionality like rate limiting, circuit breaking, load balancing, and distributed tracing — all of which are generally agnostic to business domain.