vitess

module
v0.0.0-...-685946b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2013 License: BSD-3-Clause

README

Vitess

Vitess is a set of servers and tools meant to facilitate scaling of MySQL databases for the web. It's currently used as a fundamental component of YouTube's MySQL infrastructure.

Features

This is an incomplete list of Vitess features.

Clients
  • A Python DBAPI 2.0 compliant client interface.
  • A go client interface.
  • Simple BSON based protocol with SASL authentication.
vttablet

Smart middleware sitting in front of MySQL and serving clients requests.

  • Connection pooling.
  • SQL parser: Although very close, the vtocc SQL parser is not SQL-92 compliant. It has left out constructs that are deemed uncommon or OLTP-unfriendly. It should, however, allow most queries used by a well-behaved web application.
  • Query rewrite and sanitation (adding limits, avoiding non-deterministic updates).
  • Query consolidation: reuse the results of an in-flight query to any subsequent requests that were received while the query was still executing.
  • Row cache: the mysql buffer cache is optimized for range scans over indices and tables, particularly when data is densely packed. Unfortunately, it’s not good for random access tables. The rowcache will instead maintain row based caches (using memcached as its backend) and keep them consistent by fielding all DMLs that could potentially affect them.
  • DML annotation: Every DML is rewritten to include a comment field at the end of a query identifying the primary key of the rows it changed.
  • Integrated query killer for queries that take too long to return data.
  • Discard idle backend connections to avoid offline db errors.
  • Transaction management: Ability to limit the number of concurrent transactions and manage deadlines.
Management
  • Cluster configuration is stored using pluggable lock service backends, with the ZooKeeper enabled by default.
  • vtctl: command line tool that allows to do most management operations, like initializing a server, changing its type, etc.
  • Separate replication and serving graph management.
  • vtctld: HTTP daemon giving an overview of the configuration (there's also a JSON API available).
  • Fast database snaphsotting and reloading (much faster than mysqldump and LOAD DATA INFILE).
Sharding
  • Keyspaces: All tables in a sharded database need to contain a “key” column. Vitess will use these values to decide the target shard for such data. All tables that are indexed by a set of keys are known as a keyspace, which basically represents the logical database that combines all the shards that store them.
  • Range based sharding: The main advantage of this scheme is that the shard map is a simple in-memory lookup. The downside of this scheme is that it creates hot-spots for sequentially increasing keys. In such cases, we recommend that the application hash the keys so they distribute more randomly.
Replication
  • Split replication: replicate only part of the replication stream basing on provided criteria (useful for vertical or horizontal resharding).
Tools
  • zkocc: ZooKeeper connection pooler and cache.
  • zkctl: manage ZooKeeper instances.
  • mysqlctl: manage MySQL instances.
  • zk: command line ZooKeeper client and explorer.

Dependencies

Development

Install Go.

cd $WORKSPACE
sudo apt-get install automake libtool flex bison memcached python-dev python-mysqldb libssl-dev g++ mercurial git
go get code.google.com/p/opts-go
git clone git@github.com:youtube/vitess.git src/github.com/youtube/vitess
cd src/github.com/youtube/vitess
./bootstrap.sh
. ./dev.env

Optionally:

VTDATAROOT=... #  $VTROOT/vt if not set
VTPORTSTART=15000

To run the tests:

make  # run the tests

License

Unless otherwise noted, the vitess source files are distributed under the BSD-style license found in the LICENSE file.

Directories

Path Synopsis
go
bufio2
Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer object, creating another object (Reader or AsyncWriter) that also implements the interface but provides buffering and some help for textual I/O.
Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer object, creating another object (Reader or AsyncWriter) that also implements the interface but provides buffering and some help for textual I/O.
cache
The implementation borrows heavily from SmallLRUCache (originally by Nathan Schrenk).
The implementation borrows heavily from SmallLRUCache (originally by Nathan Schrenk).
cmd/normalizer
normalizer takes a file of sql statements as input and converts the statements into normalized sql statements with bind variables.
normalizer takes a file of sql statements as input and converts the statements into normalized sql statements with bind variables.
cmd/vttablet
vt tablet server: Serves queries and performs housekeeping jobs.
vt tablet server: Serves queries and performs housekeeping jobs.
db
flagutil
Package flagutil contains flags that parse string lists and string maps.
Package flagutil contains flags that parse string lists and string maps.
netutil
This packages contains a few utility functions for network related functions.
This packages contains a few utility functions for network related functions.
pools
Package pools provides functionality to manage and reuse resources like connections.
Package pools provides functionality to manage and reuse resources like connections.
proc
Package proc allows you to configure servers to be restarted with negligible downtime.
Package proc allows you to configure servers to be restarted with negligible downtime.
rpcplus
Package rpc provides access to the exported methods of an object across a network or other I/O connection.
Package rpc provides access to the exported methods of an object across a network or other I/O connection.
rpcplus/jsonrpc
Package jsonrpc implements a JSON-RPC ClientCodec and ServerCodec for the rpc package.
Package jsonrpc implements a JSON-RPC ClientCodec and ServerCodec for the rpc package.
sqltypes
Package sqltypes implements interfaces and types that represent SQL values.
Package sqltypes implements interfaces and types that represent SQL values.
stats
Package stats is a wrapper for expvar.
Package stats is a wrapper for expvar.
tb
timer
Package timer provides timer functionality that can be controlled by the user.
Package timer provides timer functionality that can be controlled by the user.
vt/client2/tablet
API compliant to the requirements of database/sql Open expects name to be "hostname:port/keyspace/shard" For query arguments, we assume place-holders in the query string in the form of :v0, :v1, etc.
API compliant to the requirements of database/sql Open expects name to be "hostname:port/keyspace/shard" For query arguments, we assume place-holders in the query string in the form of :v0, :v1, etc.
vt/dbconfigs
Package dbconfigs is reusable by vt tools to load the db configs file.
Package dbconfigs is reusable by vt tools to load the db configs file.
vt/topo/test
package test contains utilities to test topo.Server implementations.
package test contains utilities to test topo.Server implementations.
vt/topotools
topotools package contains a few utility classes to handle topo.Server objects, and transitions.
topotools package contains a few utility classes to handle topo.Server objects, and transitions.
vt/vtgate
Package vtgate provides query routing rpc services for vttablets.
Package vtgate provides query routing rpc services for vttablets.
vt/vttablet
Package vttablet contains the meat of the vttablet binary.
Package vttablet contains the meat of the vttablet binary.
zk
Emulate a "global" namespace across n zk quorums.
Emulate a "global" namespace across n zk quorums.
zk/fakezk
Package fakezk is a pretty complete mock implementation of a Zookeper connection (see go/zk/zk.Conn).
Package fakezk is a pretty complete mock implementation of a Zookeper connection (see go/zk/zk.Conn).
zk/zkocc
cache for zkocc
cache for zkocc
test
third_party
go/launchpad.net/gozk/zookeeper
gozk - ZooKeeper support for the Go language
gozk - ZooKeeper support for the Go language

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL