MyCat Overview
MyCat is an open-source distributed database middleware that fully implements the MySQL protocol. Frontend users can directly connect to MyCat using standard MySQL client tools, just like operating an ordinary MySQL database.
Core Features:
- Database & Table Sharding (Horizontal Splitting): Supports range, hash, time and other sharding strategies
- Read-Write Separation: Automatically routes write operations to master, read operations to slaves
- Result Set Merging: Merges result sets from multiple shards
- SQL Interception & Rewriting
- Database Firewall
- Heartbeat Detection & Failover
Typical Use Cases:
- E-commerce system order table sharded storage
- IoT massive device data storage
- Multi-tenant SaaS applications
MyCat Role Definition
For DBAs
From DBA perspective, MyCat is a virtual MySQL Server instance:
- No data storage characteristic: MyCat itself does not store any business data
- Data reliability guarantee: Completely relies on underlying MySQL database’s transaction mechanism
- O&M management advantage: Simplifies operational complexity of large-scale MySQL clusters
Value for Developers
- Connection compatibility: Supports all standard MySQL connection methods
- ORM framework support: Compatible with mainstream ORM frameworks
- Best practices: For sharded tables, using native SQL is recommended for optimal performance
Core Concepts
Logical Database
Logical database is an abstract representation of a physical sharded database cluster. It provides a unified virtual database view to applications, hiding the complex underlying physical sharding structure.
Logical Table
Logical table is a virtual data table facing application programs, whose expression is completely consistent with traditional single-machine database tables. Developers can perform CRUD operations on logical tables using standard SQL statements.
Sharded Table
Sharded table refers to a large data table originally stored in a single database, split into multiple smaller parts according to specific rules.
Typical Implementation Methods:
- Horizontal sharding: Range sharding, hash sharding, time sharding
- Sharding strategy: By user ID hash, by time range, etc.
Non-Sharded Table
Non-sharded table refers to tables that do not require data partitioning, usually stored completely on a single database node.
Applicable Scenarios:
- Tables with small data volume
- Tables with low access frequency
- Tables requiring global consistency
Performance Metrics
- Up to 100,000 QPS
- Single node manages 100+ physical shards
- Millisecond-level fault detection and switching