Skip to content

Kratos

A lightweight Go framework for building cloud-native microservices.

Stars
26k
Forks
4.2k
Licence
MIT
Language
Go
Last update
5 days ago
Type
Library

What it is

Kratos is a Go framework for building microservices, the small backend services that together make up a larger application. It provides APIs for handling HTTP and gRPC traffic, middleware, service registry, configuration, logging, and code generation from Protobuf definitions, so developers can focus on business logic. It is maintained as an open-source project under the MIT license.

  • Generate a starter service with the kratos CLI and run it locally on port 8000
  • Define an API in a .proto file and generate matching HTTP and gRPC server and client code
  • Add middleware for recovery, logging, validation, tracing, or auth to a service
  • Connect a service to a pluggable registry or configuration store through contrib packages

Great for

  • Go developers building a set of backend services that talk over HTTP or gRPC
  • Teams that want an API-first workflow starting from Protobuf definitions
  • Developers who want a lightweight framework with explicit, composable components
  • Teams moving to cloud-native deployments who want pluggable registries and configuration

Not ideal for

  • Developers who do not use Go, since the framework is written for Go only
  • Beginners with no Go or Protobuf experience, because the setup requires installing protoc and protoc-gen-go first
  • Teams planning to upgrade from v2 without reviewing the migration guide, since v3 changes implicit behavior
Step-by-step guide: how to use KratosInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Go 1.25 or later · protoc · protoc-gen-go

    Install the CLI

    go install github.com/go-kratos/kratos/cmd/kratos/v3@latest

    Upgrade the CLI tooling

    kratos upgrade
  2. 2

    Run it

    • Create a new service with kratos new helloworld
    • Enter the folder and run go mod tidy
    • Start the service with kratos run
    • Visit http://localhost:8000/helloworld/kratos to see the response
  3. 3

    Get the most out of it

    • Use kratos proto add, kratos proto client, and kratos proto server to scaffold API definitions and service code from Protobuf
    • Run go generate ./... after changing Protobuf files to regenerate code
    • Review the v2 to v3 migration guide in docs/migration/v2-to-v3.md before upgrading production services
    • Browse the examples repository and kratos-layout project for fuller reference setups
    • Use contrib packages to add optional registries, config stores, and OpenTelemetry observability

Downloads

Strengths

  • Unified transport layer covering both HTTP and gRPC
  • Composable middleware and pluggable components for registry, config, and encoding
  • Uses the standard library log/slog for logging, with OpenTelemetry extensions in contrib packages

Trade-offs

  • Requires several tools to be installed before a first generated service runs (Go 1.25+, protoc, protoc-gen-go)
  • The latest release v3.0.0 has no prebuilt binaries, so installation goes through Go tooling
  • Upgrading from v2 requires reading the migration guide because v3 changes previously implicit behavior

How it compares

ProjectStarsTypeLevelUpdatedBest for
kratos (this)26kLibraryintermediate5 days agoGo developers building a set of backend services that talk over HTTP or gRPC
go-zero33.4kLibraryintermediate5 days agoGo developers building REST APIs or microservices
chi23kLibraryintermediate19 days agoGo developers building REST API services
gf13.3kFrameworkintermediate7 days agoGo developers looking for a full-featured framework
grpcurl12.9kCLIbeginner24 days agoBackend engineers testing gRPC endpoints during development
kit27.4kLibraryadvanced2.3 years agoGo developers building service-oriented or microservice backends

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.