What TiDB Does
- Distributed SQL — horizontal scaling like NoSQL but with SQL and ACID
- MySQL compatible — wire protocol + most MySQL syntax
- HTAP — row-store (TiKV) + column-store (TiFlash) for mixed workloads
- Raft consensus — strong consistency across replicas
- Elastic scale — add nodes without downtime
- Online DDL — schema changes without locks
- Auto-sharding — data automatically partitioned and rebalanced
- Cross-region clusters — geo-distributed deployments
Architecture
Three layers:
- TiDB servers — stateless SQL layer, parse/plan/execute queries
- TiKV — distributed KV store (Rust), uses Raft for replication
- PD (Placement Driver) — cluster metadata and scheduling
- TiFlash (optional) — columnar replica for analytics
Self-Hosting
# Production deployment
tiup cluster deploy mycluster v7.5.0 topology.yaml
tiup cluster start mycluster
tiup cluster display mycluster
# Scale out
tiup cluster scale-out mycluster scale.yamlKey Features
- MySQL 5.7/8.0 compatibility
- Distributed SQL with ACID
- HTAP (TiFlash columnar)
- Elastic horizontal scaling
- Online DDL
- Point-in-time recovery
- Encryption at rest
- Cloud-ready (TiDB Cloud managed service)
- PingCAP official tools ecosystem
Comparison
| Database | Model | SQL Standard | Scaling |
|---|---|---|---|
| TiDB | Distributed SQL | MySQL-compatible | Horizontal |
| CockroachDB | Distributed SQL | PostgreSQL-compatible | Horizontal |
| YugabyteDB | Distributed SQL | PostgreSQL-compatible | Horizontal |
| Spanner | Distributed SQL | Managed | Managed |
| Vitess | MySQL sharding | MySQL | Horizontal |
| MySQL Group Replication | HA cluster | MySQL | Vertical + replicas |
常见问题 FAQ
Q: 能替换 MySQL 吗? A: 在大部分场景可以,兼容率 95%+。但某些 MySQL 特性(如 event scheduler、存储引擎指定)不支持。迁移前做兼容测试。
Q: TiFlash 是什么? A: 列式副本,同步 TiKV 数据到列存储,加速分析查询。同一张表可以同时有行存(OLTP)和列存(OLAP)。
Q: 最小生产部署? A: 3 PD + 3 TiKV + 2 TiDB = 8 节点。TiFlash 可选。TiDB Cloud 最小 3 节点。
来源与致谢 Sources
- Docs: https://docs.pingcap.com/tidb
- GitHub: https://github.com/pingcap/tidb
- License: Apache 2.0