Vitess — Horizontal Scaling for MySQL Through Sharding
A CNCF graduated database clustering system for horizontal scaling of MySQL. Born at YouTube to handle massive traffic, Vitess adds sharding, connection pooling, and query routing to MySQL without changing application code.
What it is
Vitess is a database clustering system designed to scale MySQL horizontally. Developed at YouTube to handle billions of requests per day, it is now a CNCF graduated project. Vitess wraps MySQL with intelligent query routing, connection pooling, and automated sharding without requiring changes to application code.
Vitess is built for database administrators and backend engineers who need to scale MySQL beyond single-server limits while maintaining compatibility with existing applications.
How it saves time or tokens
Vitess handles the hard parts of database scaling: deciding which shard holds which data, routing queries to the right shard, managing connection pools, and handling schema migrations across shards. Without Vitess, teams spend months building custom sharding layers. Vitess provides this out of the box with a MySQL-compatible protocol.
How to use
- Clone and start a local Vitess cluster:
git clone https://github.com/vitessio/vitess.git
cd vitess/examples/local
./101_initial_cluster.sh
- Connect via VTGate (the Vitess query router):
mysql -h 127.0.0.1 -P 15306
- Your application connects to VTGate as if it were MySQL
Example
-- Connect to VTGate and work as if it is normal MySQL
mysql -h 127.0.0.1 -P 15306
-- Create a keyspace (Vitess equivalent of a database)
-- This is handled via vtctlclient:
-- vtctlclient CreateKeyspace commerce
-- Create a sharded table with vindex
CREATE TABLE users (
id BIGINT NOT NULL AUTO_INCREMENT,
name VARCHAR(255),
email VARCHAR(255),
PRIMARY KEY (id)
) ENGINE=InnoDB;
-- Queries are automatically routed to the correct shard
SELECT * FROM users WHERE id = 12345;
INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com');
Related on TokRepo
- Database tools — database management and scaling resources
- DevOps tools — infrastructure management
Common pitfalls
- Not choosing the right sharding key (vindex), which leads to hotspots on a single shard
- Running cross-shard queries that perform scatter-gather, negating the scaling benefits
- Underestimating the operational complexity of managing a Vitess cluster in production
Frequently Asked Questions
Yes. VTGate speaks the MySQL protocol. Your application connects to VTGate as if it were a MySQL server. However, some cross-shard queries may behave differently, so testing is necessary.
ProxySQL focuses on connection pooling and query routing for read replicas. Vitess provides full horizontal sharding, automated shard management, and online schema migrations. They solve different scaling problems.
Vitess was built at YouTube and is used by Slack, GitHub, Square, HubSpot, and many other companies that need to scale MySQL beyond single-server limits.
Yes. Vitess includes built-in online DDL support that applies schema changes across all shards without downtime. It uses a combination of gh-ost and pt-online-schema-change under the hood.
VTGate is the stateless query router that sits between your application and the MySQL shards. It parses queries, determines which shard to route them to, and handles connection pooling. Your application only connects to VTGate.
Citations (3)
- Vitess GitHub— Vitess is a CNCF graduated project born at YouTube
- Vitess Documentation— MySQL-compatible sharding and query routing
- CNCF— CNCF graduated project
Related on TokRepo
Discussion
Related Assets
Conda — Cross-Platform Package and Environment Manager
Install, update, and manage packages and isolated environments for Python, R, C/C++, and hundreds of other languages from a single tool.
Sphinx — Python Documentation Generator
Generate professional documentation from reStructuredText and Markdown with cross-references, API autodoc, and multiple output formats.
Neutralinojs — Lightweight Cross-Platform Desktop Apps
Build desktop applications with HTML, CSS, and JavaScript using a tiny native runtime instead of bundling Chromium.