Vitessとは • シャーディングによるMySQLの水平スケーリング のためのデータベース・クラスタリングシステム • YouTubeによって開発された技術 – First Commit in 2010 – In Production at YouTube since 2011 • CNCFに16番目にホストされたプロジェクト(現 在はIncubating) 6 今回はKubernetes上で動作させる前提で調査・検証しました。 i
Vitess in Kubernetes 14 pod pod app server pod etcd VTgate service etcd service pod pod VTctld VTctld service Admin pod batch job VTgate pod Shard 1 Shard 2 tablet tablet Master Replica Ronly Master Replica Ronly PV PV
負荷分散による性能向上 • 複数tablet(Shard)を跨るクエリーを実行 26 G LoadBalancer Sysbench M Ro Rp G Vtgate M Ro Rp M Ro Rp M Ro Rp フル・ス キャン クエリー 100万件のテーブルデータを 4分割(約25万件/Shard) SQL
負荷分散による性能向上:準備 • データ増幅 • クエリー 28 create procedure insert_messages(in x int) begin declare i int; set i = 0; set i = i + 1; INSERT INTO messages (page, time_created_ns, message) VALUES ( i, i+cast(now() as datetime) , SUBSTRING(MD5(RAND()), 1, 10)); end while; end ; call insert_messages(1000000); > select * from messages where message like '%abc%’; +----+-------------+----------+------------+- | id | select_type | table | partitions | +----+-------------+----------+------------+- | 1 | SIMPLE | messages | NULL | +----+-------------+----------+------------+-
スケーラビリティ:準備 • クエリーは2パターン用意 – 1. Simple:索引を利用したシンプルなクエリーのみ – 2. Default:1. SimpleクエリーとWhere句にbetweenを含むクエリー • oltp_read_only.luaスクリプトを使用 • betweenはシャードをまたがって処理される 38 > select c from sbtest1 where id = :vtg1 > select c from sbtest1 where id = :vtg1 > select distinct c, weight_string(c) from sbtest1 where id between :vtg1 and :vtg2 order by c asc > select SUM(k) from sbtest1 where id between :vtg1 and :vtg2 > select c from sbtest1 where id between :vtg1 and :vtg2 > select c, weight_string(c) from sbtest1 where id between :vtg1 and :vtg2 order by c asc 1. Simple 2. Default