Skip to main content

Introduction to Kratos

The name is inspired by the Greek-mythology-based game “God of War”. It tells the adventures of Kratos becoming a god of war from a mortal and launching a god-killing slaughter.
Kratos is a microservice-oriented governance framework implemented by Go, which offers convenient capabilities to help you quickly build bulletproof applications from scratch.

Why Kratos?

Kratos boosts your productivity by providing battle-tested abstractions for common microservice patterns. With the integration of excellent resources and built-in support for distributed systems challenges, programmers can focus on business logic while the framework handles the infrastructure concerns.

Quick Start

Get a working service running in minutes

Installation

Install the Kratos CLI and dependencies

Architecture

Understand Kratos’s design principles

API Documentation

Explore the complete API reference

Key Features

Protobuf-Based API Definition

Define your APIs using Protocol Buffers and automatically generate client and server code. Kratos supports both HTTP and gRPC transports from a single .proto definition.
service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "/helloworld/{name}"
    };
  }
}

Transport Abstraction

Kratos provides a unified transport layer that abstracts HTTP and gRPC, allowing you to switch between protocols without changing your business logic.
  • HTTP: Built on gorilla/mux with RESTful routing
  • gRPC: Native gRPC support with protobuf
  • Unified metadata: Consistent metadata handling across transports

Comprehensive Middleware System

Extend and customize your services with powerful middleware support:
  • Tracing: OpenTelemetry integration for distributed tracing
  • Metrics: Prometheus metrics out of the box
  • Recovery: Panic recovery and error handling
  • Logging: Structured logging with pluggable backends
  • Validation: Automatic request validation from protobuf definitions
  • Rate Limiting: Circuit breakers and rate limiting

Service Registry and Discovery

Pluggable service registry interface supporting multiple backends:
  • Consul
  • Etcd
  • Nacos
  • Kubernetes
  • Custom implementations

Dynamic Configuration

Manage application configuration from multiple sources with hot-reload support:
  • File-based configuration (YAML, JSON, TOML)
  • Environment variables
  • Remote configuration centers
  • Atomic configuration updates

CLI Tool for Scaffolding

The kratos CLI accelerates development with code generation:
# Create a new project
kratos new helloworld

# Generate service code from protobuf
kratos proto client api/helloworld/v1/greeter.proto

# Add a new service to your project
kratos proto add api/user/v1/user.proto

Design Principles

Kratos follows these core principles:
  • Simple: Appropriate design with plain and easy code
  • General: Cover various utilities for business development
  • Highly efficient: Speed up business development and deployment
  • Stable: Production-validated base libraries with high testability
  • Robust: Eliminate misuse through high-quality abstractions
  • High-performance: Optimal performance without unsafe hacks
  • Expandability: Well-designed interfaces for extensibility
  • Fault-tolerance: Built-in resilience patterns

What’s Next?

Get Started

Build your first Kratos service in 5 minutes

Core Concepts

Learn about Kratos architecture and components

Examples

Explore example projects and patterns

Community

Join the Kratos community

Community and Support

License

Kratos is open-source software licensed under the MIT license.

Build docs developers (and LLMs) love