Kratos
Your ultimate Go microservices framework for the cloud-native era.
Last verified:
What is Kratos?
Kratos is a lightweight Go microservices framework designed for building cloud-native applications. Created by Bilibili, it is a microservice-oriented governance framework implemented in Golang that offers convenient capabilities to help developers quickly build bulletproof applications from scratch. The framework is named after the protagonist from the game God of War, symbolizing the journey from ordinary to powerful.
Key features include support for HTTP/gRPC transport protocols based on Protobuf definitions, integrated Prometheus metrics, OpenTelemetry tracing for distributed tracing, dynamic configuration with multiple data sources, standard logging interfaces with Fluentd support, automatic Swagger UI generation, middleware support for tracing/metrics/recovery, centralized registry interfaces with plugin support, and comprehensive code generation tools for API documentation, client/server code, and error codes.
Kratos is designed for Go developers building microservices who want an all-in-one solution that lets them focus on business logic rather than microservice infrastructure. It is ideal for teams building cloud-native applications who need production-ready base libraries validated in real environments, and for developers wanting to learn microservice architecture aspects through practical implementation.
The framework follows principles of simplicity, generality, high efficiency, stability, robustness, high performance, expandability, fault-tolerance, and includes an extensive toolchain for cache layer generation and linting.
Kratos pricing
Pricing model: Freemium
Kratos is completely free and open-source software licensed under the MIT license. There are no paid plans, subscription fees, or enterprise tiers. The framework, CLI tool, documentation, and all features are available at no cost. Users can use Kratos for personal, commercial, and enterprise projects without any licensing restrictions beyond the MIT license terms.
Kratos pros
- Lightweight Go framework specifically for cloud-native microservices
- All-in-one solution covering interface definition to API documentation generation
- HTTP and gRPC transport support based on Protobuf definitions
- Prometheus metrics integrated by default
- OpenTelemetry compliance for distributed tracing
- Dynamic configuration support with atomic operations
- Multiple configuration data sources supported
- Standard log interfaces easy to integrate with third-party libraries
- Automatic Swagger UI generation with embedded endpoint
- Powerful middleware design for tracing, metrics, and recovery
- Centralized registry interfaces with plugin support for various registries
- Production-validated base libraries with high testability and coverage
- Code generation for client, server, error codes, and API documentation
- Simple and plain design that is easy to code with
- Fault-tolerance designed against failure with SRE practices
- Extensive toolchain including cache layer generation and lint tools
- MIT licensed open-source software
- Comprehensive documentation with detailed usage instructions
- High performance without requiring unsafe code optimizations
Kratos cons
- Relatively incomplete ecosystem compared to mature frameworks
- Smaller community making some issues harder to resolve
- Fewer plugins and tools available compared to competitors
- Requires Go 111MODULE to be enabled
- Need to install protoc compiler separately for Protobuf
- CLI pulls layout project from GitHub which may have network issues in China
- Steeper learning curve for developers new to microservices
- Less English documentation compared to Chinese documentation
- Requires additional tools like Wire for dependency injection
Frequently asked questions about Kratos
What is Kratos?
Kratos is a microservice-oriented governance framework implemented in Golang that provides convenient capabilities to help developers quickly build bulletproof applications from scratch. It is a lightweight Go framework for building cloud-native microservices with HTTP/gRPC transport based on Protobuf definitions.
What version of Kratos is required?
The version of Kratos must be v2.0.0 or above. This is the minimum version requirement for using the framework and its CLI tools.
How do I install Kratos?
You can install Kratos in two ways: 1) Using go install: go install github.com/go-kratos/kratos/cmd/kratos/v2@latest, or 2) Source code compilation: git clone https://github.com/go-kratos/kratos, cd kratos, make install. Before installation, GO111MODULE should be enabled.
How do I create a new Kratos project?
Create a project using the Kratos CLI: run 'kratos new helloworld' to create the project layout, then cd into the directory and run 'go mod download' to pull dependencies. The CLI pulls the layout project from GitHub automatically.
What protocols does Kratos support?
Kratos implements REST (HTTP) and gRPC as the transport protocols. Messages are defined by Protobuf and used for both HTTP and gRPC transport. The framework provides uniform metadata transfer methods for both protocols.
What monitoring and observability tools does Kratos integrate?
Kratos integrates Prometheus for metrics by default, and conforms to OpenTelemetry for distributed tracing of microservice chains. It also provides standard log interfaces that ease integration with third-party logging libraries, with logs collected through Fluentd.
How do I handle configuration in Kratos?
Kratos supports multiple data sources for configurations and dynamic configurations using atomic operations. The config component allows you to manage configuration from various sources with thread-safe updates.
What is the Kratos project layout?
Kratos CLI always pulls the layout project from GitHub for project creation. The layout provides a standardized project structure. You can also use the kratos-layout template repository to contribute to the project structure development.
How do I run a Kratos application?
After creating a project and generating code with 'go generate ./...', you can run the application using 'kratos run' for development or 'go build -o ./bin/ ./...' followed by './bin/server -conf ./configs' for production.
What license is Kratos under?
Kratos is MIT licensed open-source software. This means you can freely use, modify, distribute, and sublicense the software for both personal and commercial projects with minimal restrictions.