Convert Figma logo to code with AI

vitessio logovitess

Vitess is a database clustering system for horizontal scaling of MySQL.

18,397
2,081
18,397
857

Top Related Projects

36,869

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/

29,856

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.

10,352

Distributed PostgreSQL as an extension

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.

4,535

Apache Calcite

Quick Overview

Vitess is an open-source database clustering system for horizontal scaling of MySQL. It provides a solution for deploying, scaling, and managing large clusters of MySQL instances, offering improved performance, availability, and manageability for large-scale database operations.

Pros

  • Seamless horizontal scaling of MySQL databases
  • Improved performance through intelligent query routing and caching
  • High availability with automatic failover and recovery
  • Compatible with existing MySQL ecosystem tools and applications

Cons

  • Complex setup and configuration process
  • Steep learning curve for new users
  • Potential overhead for smaller-scale deployments
  • Limited support for some advanced MySQL features

Code Examples

  1. Connecting to a Vitess cluster using Go:
import (
    "database/sql"
    "vitess.io/vitess/go/vt/vitessdriver"
)

func main() {
    db, err := vitessdriver.Open("localhost:15991", "keyspace")
    if err != nil {
        log.Fatal(err)
    }
    defer db.Close()

    // Use db for queries
}
  1. Executing a query with bind variables:
query := "SELECT * FROM users WHERE id = :id"
rows, err := db.Query(query, sql.Named("id", 123))
if err != nil {
    log.Fatal(err)
}
defer rows.Close()

// Process query results
  1. Using a transaction:
tx, err := db.Begin()
if err != nil {
    log.Fatal(err)
}

_, err = tx.Exec("INSERT INTO users (name, email) VALUES (?, ?)", "John Doe", "john@example.com")
if err != nil {
    tx.Rollback()
    log.Fatal(err)
}

err = tx.Commit()
if err != nil {
    log.Fatal(err)
}

Getting Started

To get started with Vitess:

  1. Install Vitess using Docker:

    docker pull vitess/vitess:latest
    
  2. Start a local Vitess cluster:

    docker run -p 15991:15991 vitess/vitess:latest ./vttestserver
    
  3. Connect to the cluster using your preferred MySQL client or programming language driver.

  4. Create a keyspace and shard:

    vtctlclient -server localhost:15999 CreateKeyspace my_keyspace
    vtctlclient -server localhost:15999 CreateShard my_keyspace/0
    
  5. Start using Vitess with your application, leveraging its scaling and management features.

Competitor Comparisons

36,869

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/

Pros of TiDB

  • Fully distributed architecture, offering better scalability for large datasets
  • Built-in support for HTAP (Hybrid Transactional/Analytical Processing) workloads
  • More comprehensive SQL compatibility, including support for complex joins and subqueries

Cons of TiDB

  • Higher resource requirements and potentially more complex setup process
  • Less mature ecosystem compared to Vitess, which has been battle-tested at large scale
  • Steeper learning curve for administrators unfamiliar with distributed systems

Code Comparison

TiDB (SQL-like syntax):

CREATE TABLE users (
  id INT PRIMARY KEY,
  name VARCHAR(255),
  created_at TIMESTAMP
);

Vitess (VSchema definition):

{
  "sharded": true,
  "vindexes": {
    "hash": {
      "type": "hash"
    }
  },
  "tables": {
    "users": {
      "column_vindexes": [
        {
          "column": "id",
          "name": "hash"
        }
      ]
    }
  }
}

Both projects aim to solve database scaling challenges, but TiDB offers a more unified, SQL-compatible approach, while Vitess focuses on sharding and scaling existing MySQL deployments. TiDB may be better suited for greenfield projects with complex query requirements, while Vitess excels in gradually scaling existing MySQL-based applications.

29,856

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.

Pros of CockroachDB

  • Built-in horizontal scalability and distributed architecture
  • Strong consistency and ACID transactions across distributed nodes
  • Native multi-region support for global deployments

Cons of CockroachDB

  • Higher resource consumption compared to traditional databases
  • Steeper learning curve for optimization and tuning
  • Limited support for legacy applications and specific SQL features

Code Comparison

CockroachDB:

CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name STRING,
  created_at TIMESTAMP DEFAULT current_timestamp()
);

Vitess:

CREATE TABLE users (
  id BINARY(16) PRIMARY KEY,
  name VARCHAR(255),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Both projects aim to provide scalable database solutions, but they take different approaches. CockroachDB is a distributed SQL database built from the ground up, while Vitess is a database clustering system for MySQL.

CockroachDB offers native distributed capabilities, making it easier to scale horizontally and deploy globally. It provides strong consistency across nodes, which can be advantageous for certain use cases.

Vitess, on the other hand, builds upon the widely-used MySQL ecosystem, potentially offering an easier migration path for existing MySQL users. It may have lower resource requirements and be more suitable for applications that don't need the full distributed capabilities of CockroachDB.

The code comparison shows slight differences in syntax and data types, reflecting the underlying architectures of each system.

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.

Pros of YugabyteDB

  • Built-in support for distributed ACID transactions across multiple nodes
  • Native multi-region and multi-cloud deployment capabilities
  • Offers both SQL (PostgreSQL-compatible) and NoSQL (Cassandra-compatible) APIs

Cons of YugabyteDB

  • Relatively newer project with a smaller community compared to Vitess
  • May require more resources for small-scale deployments
  • Limited ecosystem of tools and integrations compared to MySQL-based solutions

Code Comparison

YugabyteDB (SQL API):

CREATE TABLE users (
  id INT PRIMARY KEY,
  name TEXT,
  email TEXT
);

Vitess:

CREATE TABLE users (
  id INT,
  name VARCHAR(255),
  email VARCHAR(255),
  PRIMARY KEY (id)
) ENGINE=InnoDB;

Both projects aim to provide scalable database solutions, but they take different approaches. YugabyteDB is a distributed SQL database built from the ground up, while Vitess is a scaling solution for MySQL. YugabyteDB offers more flexibility in terms of data models and deployment options, but Vitess benefits from the mature MySQL ecosystem and may be easier to adopt for existing MySQL users.

10,352

Distributed PostgreSQL as an extension

Pros of Citus

  • Native PostgreSQL extension, allowing seamless integration with existing PostgreSQL ecosystems
  • Supports both distributed tables and local tables, offering flexibility in data distribution
  • Easier to set up and maintain, as it builds on standard PostgreSQL infrastructure

Cons of Citus

  • Limited to PostgreSQL, not suitable for other database systems
  • Scaling out requires manual intervention and data redistribution
  • Less mature ecosystem compared to Vitess, with fewer tools and integrations

Code Comparison

Citus (SQL extension):

CREATE TABLE distributed_table (id int, name text);
SELECT create_distributed_table('distributed_table', 'id');

Vitess (VTGate query):

USE `keyspace`;
INSERT INTO distributed_table (id, name) VALUES (1, 'example');

Key Differences

  • Citus extends PostgreSQL, while Vitess is database-agnostic and primarily used with MySQL
  • Vitess offers more advanced sharding and routing capabilities out-of-the-box
  • Citus provides a more familiar PostgreSQL experience for developers and DBAs
  • Vitess has better support for large-scale deployments and automated scaling
  • Citus is easier to adopt for existing PostgreSQL users, while Vitess requires more setup and configuration

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.

Pros of ShardingSphere

  • More flexible sharding strategies, supporting complex sharding algorithms
  • Broader database support, including MySQL, PostgreSQL, Oracle, and SQL Server
  • Provides a unified API for different databases, simplifying application development

Cons of ShardingSphere

  • Steeper learning curve due to more complex configuration options
  • Less mature ecosystem compared to Vitess, with fewer production deployments at scale
  • Lacks built-in support for advanced features like online schema changes

Code Comparison

ShardingSphere configuration example:

spring:
  shardingsphere:
    datasource:
      names: ds0,ds1
    sharding:
      tables:
        t_order:
          actual-data-nodes: ds$->{0..1}.t_order_$->{0..1}
          database-strategy:
            inline:
              sharding-column: user_id
              algorithm-expression: ds$->{user_id % 2}

Vitess configuration example:

vschema:
  sharded:
    vindexes:
      hash:
        type: hash
    tables:
      t_order:
        column_vindexes:
          - column: user_id
            name: hash

Both projects aim to solve database scaling challenges, but ShardingSphere offers more flexibility at the cost of complexity, while Vitess provides a more opinionated and battle-tested solution with a focus on MySQL compatibility.

4,535

Apache Calcite

Pros of Calcite

  • More flexible query optimization framework, supporting various data sources beyond just relational databases
  • Extensive SQL dialect support, including advanced features like temporal tables and streaming queries
  • Easier integration with existing Java-based data processing systems

Cons of Calcite

  • Steeper learning curve due to its more abstract and generic nature
  • Less out-of-the-box scalability features compared to Vitess's built-in sharding capabilities
  • Potentially higher overhead for simple use cases that don't require advanced query optimization

Code Comparison

Calcite (SQL parsing):

String sql = "SELECT * FROM emp WHERE deptno = 10";
SqlParser.Config config = SqlParser.config().withCaseSensitive(false);
SqlParser parser = SqlParser.create(sql, config);
SqlNode sqlNode = parser.parseQuery();

Vitess (query execution):

qr, err := conn.ExecuteFetch("SELECT * FROM employees WHERE department_id = 10", 1000, true)
if err != nil {
    log.Fatalf("ExecuteFetch failed: %v", err)
}

Both projects offer powerful database management capabilities, but they serve different purposes. Calcite focuses on query optimization and SQL parsing across various data sources, while Vitess specializes in scaling and managing large MySQL deployments.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Maven Central Coverage Status Go Report Card FOSSA Status CII Best Practices OpenSSF Scorecard

Vitess

Vitess is a database clustering system for horizontal scaling of MySQL through generalized sharding.

By encapsulating shard-routing logic, Vitess allows application code and database queries to remain agnostic to the distribution of data onto multiple shards. With Vitess, you can even split and merge shards as your needs grow, with an atomic cutover step that takes only a few seconds.

Vitess has been a core component of YouTube's database infrastructure since 2011, and has grown to encompass tens of thousands of MySQL nodes.

For more about Vitess, please visit vitess.io.

Vitess has a growing community. View the list of adopters.

Reporting a Problem, Issue, or Bug

To report a problem, create a GitHub issue.

For topics that are better discussed live, please join the Vitess Slack workspace. You may post any questions on the #general channel or join some of the special-interest channels.

Follow Vitess Blog for low-frequency updates like new features and releases.

Security

Reporting Security Vulnerabilities

To report a security vulnerability, please email vitess-maintainers.

See Security for a full outline of the security process.

Security Audit

A third party security audit was performed by ADA Logics. Read the full report.

License

Unless otherwise noted, the Vitess source files are distributed under the Apache Version 2.0 license found in the LICENSE file.

FOSSA Status