Introduction
Kitex is a Go RPC framework created by ByteDance as part of the CloudWeGo open-source initiative. It is designed for microservice architectures that demand low latency, high throughput, and extensible middleware, providing built-in support for Thrift, Protobuf, and gRPC transports.
What Kitex Does
- Generates Go server and client code from Thrift or Protobuf IDL files
- Provides high-performance network transport with connection pooling and multiplexing
- Includes built-in service governance: circuit breaker, retry, timeout, and load balancing
- Supports middleware chains for logging, tracing, and metrics collection
- Integrates with service registries like etcd, Nacos, ZooKeeper, and Consul
Architecture Overview
Kitex uses a layered design: the code generator (kitex tool) produces typed stubs from IDL, the transport layer handles connection management and protocol encoding, and the middleware layer chains interceptors for cross-cutting concerns. The default transport uses Netpoll, a high-performance non-blocking I/O library optimized for Go, which avoids the overhead of goroutine-per-connection models under heavy load.
Self-Hosting & Configuration
- Install the code generator with
go install github.com/cloudwego/kitex/tool/cmd/kitex@latest - Define services in Thrift or Protobuf IDL files
- Run
kitex -module <mod> -service <svc> <idl>to generate server scaffolding - Configure timeouts, retries, and circuit breakers via client options in code
- Register with etcd or Nacos for service discovery in production
Key Features
- Netpoll-based transport delivering low-latency RPC under high concurrency
- Multi-protocol support: Thrift, Protobuf, and gRPC interoperability
- Pluggable middleware for observability, auth, and rate limiting
- Connection multiplexing reduces resource usage for large service graphs
- Generic call support for dynamic invocation without compiled stubs
Comparison with Similar Tools
- gRPC-Go — widely adopted but limited to Protobuf; Kitex also supports Thrift natively
- Dubbo-Go — Java-ecosystem heritage; Kitex is Go-native with Netpoll optimization
- Kratos — Bilibili's Go framework with HTTP focus; Kitex targets pure RPC workloads
- go-micro — higher-level abstraction; Kitex offers more control over transport and encoding
- Twirp — simple Protobuf-over-HTTP; Kitex supports persistent connections and multiplexing
FAQ
Q: Can Kitex interoperate with gRPC services? A: Yes, Kitex supports the gRPC protocol, so Kitex clients can call standard gRPC servers and vice versa.
Q: What serialization formats does Kitex support? A: Thrift (binary, compact), Protobuf, and Flatbuffers via the code generator.
Q: How does Kitex handle service discovery? A: Kitex provides resolver interfaces with official extensions for etcd, Nacos, ZooKeeper, Consul, and Polaris.
Q: Is Kitex production-ready? A: Kitex runs thousands of microservices at ByteDance, handling tens of millions of requests per second.