SlideShare a Scribd company logo
Introduction to Vitess
on Kubernetes for
MySQL
Alkin Tezuysal - Sr. Technical Manager, Percona
Sugu Sougoumarane - CTO/Co-Founder, PlanetScale
2020 Webinar Series - May 11th 2020
© 2020 Percona
Who are we?
Sr. Technical Manager at Percona
Open Source Database Evangelist
Global Database Operations Expert
Inspiring Technical and Strategic
Leader
Creative Team Builder
Speaker, Mentor, and Coach
Co-creator of Vitess, CTO at
PlanetScale.
Scalability at YouTube, PayPal in
the early days.
Argues about distributed systems
and consensus algorithms.
Occasionally blogs at
ssougou.blogspot.com.
2
Alkin Tezuysal - @ask_dba
Born to Sail, Forced
to Work
Sugu Sougoumarane - @ssougou
Storage Geek
@@ask_dba, @ssougou
© 2020 Percona
A Database
Clustering
System for
Horizontal
Scaling of
MySQL
3
@@ask_dba, @ssougou
© 2020 Percona
Introduction to
Vitess
4
@@ask_dba, @ssougou
© 2020 Percona
Vitess in CNCF
(Cloud Native
Computing
Foundation)
5
@@ask_dba, @ssougou
© 2020 Percona
True
Multi-Cloud
Clusters for
PlanetScaleDB
6
@@ask_dba, @ssougou
© 2020 Percona
Kubernetes on
Google Cloud
(GKE)
● Google Cloud's load-balancing for Compute Engine instances
● Node pools to designate subsets of nodes within a cluster for
additional flexibility
● Automatic scaling of your cluster's node instance count
● Automatic upgrades for your cluster's node software
● Node auto-repair to maintain node health and availability
● Logging and monitoring with Google Cloud's operations suite for
visibility into your cluster
7
@@ask_dba, @ssougou
© 2020 Percona
Installation and
Configuration
● Vitess on Google Cloud Platform Prerequisites
○ Google Kubernetes Engine (GKE)
○ Cluster with 7 nodes
○ K8s Version 1.15.11-gke.1
○ Helm Version 3
● Requirements
○ RBR
○ GTID
○ MySQL 5.6+ MariaDB 10.x+
8
@@ask_dba, @ssougou
© 2020 Percona
Create Vitess
Cluster GKE
9
@@ask_dba, @ssougou
© 2020 Percona
Setup Basics
10
@@ask_dba, @ssougou
© 2020 Percona
Configure
Cluster
11
@@ask_dba, @ssougou
© 2020 Percona
Connect to K8s
Cluster
12
@@ask_dba, @ssougou
© 2020 Percona
Download and
install Helm 3.X
$ wget https://get.helm.sh/helm-v3.1.2-linux-amd64.tar.gz
$ tar xvfz helm-v3.1.2-linux-amd64.tar.gz
$ sudo cp linux-amd64/helm /usr/local/bin/helm
$ go get vitess.io/vitess/go/cmd/vtctlclient
$ git clone git@github.com:vitessio/vitess.git
$ cd vitess/examples/helm
13
@@ask_dba, @ssougou
© 2020 Percona
Install Vitess
$ helm install vitess ../../helm/vitess -f 101_initial_cluster.yaml
NAME: vitess
LAST DEPLOYED: Thu May 7 13:55:49 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Release name: vitess
To access administrative web pages, start a proxy with:
kubectl proxy --port=8001
Then use the following URLs:
vtctld:
http://localhost:8001/api/v1/namespaces/default/services/vtctld:web/proxy/app/
vtgate:
http://localhost:8001/api/v1/namespaces/default/services/vtgate-zone1:web/proxy/
14
@@ask_dba, @ssougou
© 2020 Percona
Run Proxy and
access to Web
Portal(s)
To access administrative web pages, start a proxy with:
kubectl proxy --port=8001
Then use the following URLs:
vtctld:
http://localhost:8001/api/v1/namespaces/default/services/vtctld:web/proxy/app/
vtgate:
http://localhost:8001/api/v1/namespaces/default/services/vtgate-zone1:web/proxy/
15
@@ask_dba, @ssougou
© 2020 Percona
Vitess Control
Panel
16
@@ask_dba, @ssougou
© 2020 Percona
vtgate status
dashboard
17
@@ask_dba, @ssougou
© 2020 Percona
kubectl status
$ kubectl get pods,jobs
NAME READY STATUS RESTARTS AGE
pod/commerce-apply-schema-initial-z27sm 0/1 Completed 0 14m
pod/commerce-apply-vschema-initial-292nc 0/1 Completed 0 14m
pod/vtctld-c56d6c788-t9xlc 1/1 Running 0 14m
pod/vtgate-zone1-7d4957f6-49xsr 1/1 Running 0 14m
pod/zone1-commerce-0-init-shard-master-69fbc 0/1 Completed 0 14m
pod/zone1-commerce-0-replica-0 6/6 Running 0 14m
pod/zone1-commerce-0-replica-1 6/6 Running 0 14m
pod/zone1-commerce-0-replica-2 6/6 Running 0 14m
NAME COMPLETIONS DURATION AGE
job.batch/commerce-apply-schema-initial 1/1 59s 14m
job.batch/commerce-apply-vschema-initial 1/1 62s 14m
job.batch/zone1-commerce-0-init-shard-master 1/1 57s 14m
18
@@ask_dba, @ssougou
© 2020 Percona
Port-forwarding
kubectl port-forward service/vtctld 15000 15999 &
process_id1=$!
kubectl port-forward service/vtgate-zone1 15306:3306 15001 &
process_id2=$!
sleep 2
echo "You may point your browser to http://localhost:15000 for vtctld."
echo "You may point your browser to http://localhost:15001 for vtgate, use the
following aliases as shortcuts:"
echo 'alias vtctlclient="vtctlclient -server=localhost:15999"'
echo 'alias mysql="mysql -h 127.0.0.1 -P 15306"'
echo "Hit Ctrl-C to stop the port forwards"
wait $process_id1
wait $process_id2
19
@@ask_dba, @ssougou
© 2020 Percona
Connect to
MySQL
$ mysql
Handling connection for 15306
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 7
Server version: 5.7.9-Vitess Percona Server (GPL), Release 29, Revision 11ad961
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> show databases;
+-----------+
| Databases |
+-----------+
| commerce |
+-----------+
1 row in set (0.11 sec)
20
@@ask_dba, @ssougou
© 2020 Percona
Creating a
Keyspace
mysql> show tables;
+--------------------+
| Tables_in_commerce |
+--------------------+
| corder |
| customer |
| product |
+--------------------+
3 rows in set (0.11 sec)
$ mysql < ./vitess/examples/common/insert_commerce_data.sql
21
@@ask_dba, @ssougou
© 2020 Percona
Verify data
mysql> select * from corder; select * from customer; select * from product;
+----------+-------------+----------+-------+
| order_id | customer_id | sku | price |
+----------+-------------+----------+-------+
| 1 | 1 | SKU-1001 | 100 |
| 2 | 2 | SKU-1002 | 30 |
| 3 | 3 | SKU-1002 | 30 |
| 4 | 4 | SKU-1002 | 30 |
| 5 | 5 | SKU-1002 | 30 |
+----------+-------------+----------+-------+
5 rows in set (0.11 sec)
22
@@ask_dba, @ssougou
© 2020 Percona
Verify data
+-------------+--------------------+
| customer_id | email |
+-------------+--------------------+
| 1 | alice@domain.com |
| 2 | bob@domain.com |
| 3 | charlie@domain.com |
| 4 | dan@domain.com |
| 5 | eve@domain.com |
+-------------+--------------------+
5 rows in set (0.11 sec)
+----------+-------------+-------+
| sku | description | price |
+----------+-------------+-------+
| SKU-1001 | Monitor | 100 |
| SKU-1002 | Keyboard | 30 |
+----------+-------------+-------+
2 rows in set (0.11 sec)
23
@@ask_dba, @ssougou
© 2020 Percona
Similarities and
Differences
Similarities
● If Vitess was treated as MySQL Server, a Keyspace would be a
database.
● A Keyspace can have one or many shards
● Each Shard is one MySQL cluster: master+replicas
Differences
● If a table name is unique across all keyspaces, it can be accessed
without the qualifying it with db name
● You can “use `keyspace@master`” or “use `keyspace@replica`”
● Bypass shard routing with “use `keyspace:-80@master`”
24
@@ask_dba, @ssougou
© 2020 Percona
Moving Tables
Use case
Customer load is increasing, MySQL is reaching its limits. We want
to move the customer and corder tables to a separate MySQL
cluster, aka “unsharded keyspace”.
25
@@ask_dba, @ssougou
© 2020 Percona
Create customer
keyspace
keyspaces:
- name: "commerce"
shards:
- name: "0"
tablets:
- type: "replica"
vttablet:
replicas: 3
- name: "customer"
shards:
- name: "0"
tablets:
- type: "replica"
vttablet:
replicas: 3
26
@@ask_dba, @ssougou
© 2020 Percona
Bring up
customer
keyspace
$ helm upgrade vitess ../../helm/vitess/ -f 201_customer_tablets.yaml
Release "vitess" has been upgraded. Happy Helming!
NAME: vitess
LAST DEPLOYED: Sun May 10 14:21:14 2020
NAMESPACE: default
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
Release name: vitess
To access administrative web pages, start a proxy with:
kubectl proxy --port=8001
Then use the following URLs:
vtctld:
http://localhost:8001/api/v1/namespaces/default/services/vtctld:web/proxy/app/
vtgate:
http://localhost:8001/api/v1/namespaces/default/services/vtgate-zone1:web/proxy/
a
27
@@ask_dba, @ssougou
© 2020 Percona
Verify upgrade
zone1-customer-0-replica-0 2/2 Running 0 108s
zone1-customer-0-replica-1 2/2 Running 0 108s
zone1-customer-0-replica-2 2/2 Running 0 108s
mysql> show databases;
+-----------+
| Databases |
+-----------+
| commerce |
| customer |
+-----------+
2 rows in set (0.04 sec)
28
@@ask_dba, @ssougou
© 2020 Percona
Initiate move
tables
$ vtctlclient MoveTables -workflow=commerce2customer commerce customer
'{"customer":{}, "corder":{}}'
29
@@ask_dba, @ssougou
© 2020 Percona
Sanity check
mysql> use commerce:0
mysql> select count(*) from corder;
+----------+
| count(*) |
+----------+
| 5 |
+----------+
mysql> use customer:0
mysql> select count(*) from corder;
+----------+
| count(*) |
+----------+
| 5 |
+----------+
30
@@ask_dba, @ssougou
© 2020 Percona
VDiff
~/...vitess/examples/helm> vtctlclient VDiff customer.commerce2customer
Summary for corder: {ProcessedRows:5 MatchingRows:5 MismatchedRows:0
ExtraRowsSource:0 ExtraRowsTarget:0}
Summary for customer: {ProcessedRows:5 MatchingRows:5 MismatchedRows:0
ExtraRowsSource:0 ExtraRowsTarget:0}
31
@@ask_dba, @ssougou
© 2020 Percona
Switch Traffic
$ vtctlclient SwitchReads -tablet_type=rdonly customer.commerce2customer
$ vtctlclient SwitchReads -tablet_type=replica customer.commerce2customer
$ vtctlclient SwitchWrites customer.commerce2customer
32
@@ask_dba, @ssougou
© 2020 Percona
Clean-up $ vtctlclient DropSources customer.commerce2customer
33
@@ask_dba, @ssougou
© 2020 Percona
Reshard
Use case
Traffic has continued to grow, but the corder table is getting too big
to fit in a single database.
There is a relationship between corder and customer. It will be
beneficial to co-locate every orders with their customer rows.
Auto-inc won’t work. Solution: Vitess Sequences.
34
@@ask_dba, @ssougou
© 2020 Percona
Creating
sequences
301_customer_sharded.yaml (commerce schema)
create table customer_seq(id int, next_id bigint, cache bigint, primary key(id))
comment 'vitess_sequence';
insert into customer_seq(id, next_id, cache) values(0, 1000, 100);
create table order_seq(id int, next_id bigint, cache bigint, primary key(id)) comment
'vitess_sequence';
insert into order_seq(id, next_id, cache) values(0, 1000, 100);
35
@@ask_dba, @ssougou
© 2020 Percona
Creating
sequences
301_customer_sharded.yaml (customer VSchema)
{
"tables": {
"customer_seq": {
"type": "sequence"
},
"order_seq": {
"type": "sequence"
},
"product": {}
}
}
36
@@ask_dba, @ssougou
© 2020 Percona
301_customer_sharded.yaml (commerce
VSchema)
{
"sharded": true,
"vindexes": {
"hash": {
"type": "hash"
}
},
"tables": {
"customer": {
"column_vindexes": [
{
"column": "customer_id",
...
"corder": {
"column_vindexes": [
{
"column": "customer_id",
"name": "hash"
}
],
"auto_increment": {
"column": "order_id",
"sequence": "order_seq"
}
}
}
}
Primary
Vindexes, aka
Sharding Keys
37
@@ask_dba, @ssougou
© 2020 Percona
Apply Changes $ helm upgrade vitess ../../helm/vitess/ -f 301_customer_sharded.yaml
38
@@ask_dba, @ssougou
© 2020 Percona
- name: "customer"
shards:
- name: "0"
tablets:
- type: "replica"
vttablet:
replicas: 3
- name: "-80"
tablets:
- type: "replica"
vttablet:
replicas: 3
copySchema:
source: "customer/0"
- name: "80-"
tablets:
- type: "replica"
vttablet:
replicas: 3
copySchema:
source: "customer/0"
Create Target
Shards
39
@@ask_dba, @ssougou
© 2020 Percona
Apply Changes $ helm upgrade vitess ../../helm/vitess/ -f 302_new_shards.yaml
40
@@ask_dba, @ssougou
© 2020 Percona
Verify cluster
zone1-customer-80-x-replica-0 2/2 Running 0 115s
zone1-customer-80-x-replica-1 2/2 Running 0 115s
zone1-customer-80-x-replica-2 2/2 Running 0 115s
zone1-customer-x-80-init-shard-master-6zhhn 0/1 Completed 0 114s
zone1-customer-x-80-replica-0 2/2 Running 0 114s
zone1-customer-x-80-replica-1 2/2 Running 0 114s
zone1-customer-x-80-replica-2 2/2 Running 0 114s
41
@@ask_dba, @ssougou
© 2020 Percona
Initiate
Resharding
$ vtctlclient Reshard customer.cust2cust '0' '-80,80-'
42
@@ask_dba, @ssougou
© 2020 Percona
mysql> use customer:0
mysql> select count(*) from corder;
+----------+
| count(*) |
+----------+
| 5 |
+----------+
mysql> use customer:-80
mysql> select count(*) from corder;
+----------+
| count(*) |
+----------+
| 4 |
+----------+
mysql> use customer:80-
mysql> select count(*) from corder;
+----------+
| count(*) |
+----------+
| 1 |
+----------+
Sanity Check
43
@@ask_dba, @ssougou
© 2020 Percona
VDiff
~/...vitess/examples/helm> vtctlclient VDiff customer.cust2cust
Summary for corder: {ProcessedRows:5 MatchingRows:5 MismatchedRows:0
ExtraRowsSource:0 ExtraRowsTarget:0}
Summary for customer: {ProcessedRows:5 MatchingRows:5 MismatchedRows:0
ExtraRowsSource:0 ExtraRowsTarget:0}
44
@@ask_dba, @ssougou
© 2020 Percona
Switch over
$ vtctlclient SwitchReads -tablet_type=rdonly customer.cust2cust
$ vtctlclient SwitchReads -tablet_type=replica customer.cust2cust
$ vtctlclient SwitchWrites customer.cust2cust
45
@@ask_dba, @ssougou
© 2020 Percona
Down Shard 0
$ helm upgrade vitess ../../helm/vitess/ -f 306_down_shard_0.yaml
$ vtctlclient DeleteShard -recursive customer/0
46
@@ask_dba, @ssougou
© 2020 Percona
Tear-down
Cluster
$ helm delete vitess
$ kubectl delete pvc -l "app=vitess"
$ kubectl delete vitesstoponodes --all
47
@@ask_dba, @ssougou
© 2020 Percona
Q&A
48
@@ask_dba, @ssougou
@ 2020 Percona
Introduction to Vitess on Kubernetes for MySQL - Part I of III
Vitess.io
PlanetScale
Operating Vitess – Square
Cloud Native Computing Foundation: Home Page
CNCF Cloud Native Interactive Landscape
PlanetScaleDB delivers true multi-cloud, multi-region clusters on AWS, GCP, and Azure - Blog
Vitess Demo
References
49

More Related Content

What's hot (20)

PDF
How to shard MariaDB like a pro - FOSDEM 2021
Alkin Tezuysal
 
PDF
KubeCon_NA_2021
Alkin Tezuysal
 
PPTX
Myrocks in the wild wild west! FOSDEM 2020
Alkin Tezuysal
 
PDF
Vitess - Data on Kubernetes
Alkin Tezuysal
 
PDF
Securing your database servers from external attacks
Alkin Tezuysal
 
PPTX
Mysql ecosystem in 2019
Alkin Tezuysal
 
POTX
Serverless
Alkin Tezuysal
 
PDF
20171104 hk-py con-mysql-documentstore_v1
Ivan Ma
 
PDF
Lessons from database failures
Colin Charles
 
PDF
MySQL features missing in MariaDB Server
Colin Charles
 
PDF
Meet MariaDB Server 10.1 London MySQL meetup December 2015
Colin Charles
 
PDF
Securing your MySQL / MariaDB Server data
Colin Charles
 
PDF
High Performance Drupal with MariaDB
MariaDB Corporation
 
PDF
Webseminar: MariaDB Enterprise und MariaDB Enterprise Cluster
MariaDB Corporation
 
PDF
Modern MySQL Monitoring and Dashboards.
Mydbops
 
PDF
Mysql User Camp : 20-June-14 : Mysql Fabric
Mysql User Camp
 
PDF
Cool MariaDB Plugins
Colin Charles
 
PDF
The MySQL Server Ecosystem in 2016
Colin Charles
 
PDF
MariaDB 10.1 what's new and what's coming in 10.2 - Tokyo MariaDB Meetup
Colin Charles
 
PDF
MariaDB - the "new" MySQL is 5 years old and everywhere (LinuxCon Europe 2015)
Colin Charles
 
How to shard MariaDB like a pro - FOSDEM 2021
Alkin Tezuysal
 
KubeCon_NA_2021
Alkin Tezuysal
 
Myrocks in the wild wild west! FOSDEM 2020
Alkin Tezuysal
 
Vitess - Data on Kubernetes
Alkin Tezuysal
 
Securing your database servers from external attacks
Alkin Tezuysal
 
Mysql ecosystem in 2019
Alkin Tezuysal
 
Serverless
Alkin Tezuysal
 
20171104 hk-py con-mysql-documentstore_v1
Ivan Ma
 
Lessons from database failures
Colin Charles
 
MySQL features missing in MariaDB Server
Colin Charles
 
Meet MariaDB Server 10.1 London MySQL meetup December 2015
Colin Charles
 
Securing your MySQL / MariaDB Server data
Colin Charles
 
High Performance Drupal with MariaDB
MariaDB Corporation
 
Webseminar: MariaDB Enterprise und MariaDB Enterprise Cluster
MariaDB Corporation
 
Modern MySQL Monitoring and Dashboards.
Mydbops
 
Mysql User Camp : 20-June-14 : Mysql Fabric
Mysql User Camp
 
Cool MariaDB Plugins
Colin Charles
 
The MySQL Server Ecosystem in 2016
Colin Charles
 
MariaDB 10.1 what's new and what's coming in 10.2 - Tokyo MariaDB Meetup
Colin Charles
 
MariaDB - the "new" MySQL is 5 years old and everywhere (LinuxCon Europe 2015)
Colin Charles
 

Similar to Introduction to Vitess on Kubernetes for MySQL - Webinar (20)

PDF
Upgrade from MySQL 5.7 to MySQL 8.0
Olivier DASINI
 
PPTX
Confoo 2021 -- MySQL New Features
Dave Stokes
 
PDF
MySQL 8.0.18 - New Features Summary
Olivier DASINI
 
PDF
Ports, pods and proxies
LibbySchulze
 
PPTX
SharePoint 2010 Virtualisation - SharePoint Saturday UK
Michael Noel
 
PDF
Fast Insight from Fast Data: Integrating ClickHouse and Apache Kafka
Altinity Ltd
 
PDF
MySQL Shell - The Best MySQL DBA Tool
Miguel Araújo
 
PPTX
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
Trevor Roberts Jr.
 
PDF
PartnerSkillUp_Enable a Streaming CDC Solution
Timothy Spann
 
PDF
Percona University - ProxySQL para MySQL
Marcelo Altmann
 
PDF
Splunk configuration file for the cloud
willmorekanan
 
PPTX
SharePoint 2010 Virtualization - SharePoint Saturday L.A.
Michael Noel
 
PPTX
SharePoint 2010 Virtualization - Norway SharePoint User Group
Michael Noel
 
PDF
Minikube – get Connections in the smalles possible setup
Martin Schmidt
 
PDF
CCCEU15 run cloudstack in docker
Pierre-Luc Dion
 
PDF
CloudStack Collab Conference 2015 Run CloudStack in Docker
CloudOps2005
 
PPTX
Mueller bacdjuly2012privatepaaswithstackato-120712154134-phpapp01
Accenture
 
PPTX
High available BizTalk infrastructure on Azure IaaS
BizTalk360
 
PPTX
vBACD July 2012 - Deploying Private PaaS with ActiveState Stackato
CloudStack - Open Source Cloud Computing Project
 
PDF
Curso de MySQL 5.7
Eduardo Legatti
 
Upgrade from MySQL 5.7 to MySQL 8.0
Olivier DASINI
 
Confoo 2021 -- MySQL New Features
Dave Stokes
 
MySQL 8.0.18 - New Features Summary
Olivier DASINI
 
Ports, pods and proxies
LibbySchulze
 
SharePoint 2010 Virtualisation - SharePoint Saturday UK
Michael Noel
 
Fast Insight from Fast Data: Integrating ClickHouse and Apache Kafka
Altinity Ltd
 
MySQL Shell - The Best MySQL DBA Tool
Miguel Araújo
 
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
Trevor Roberts Jr.
 
PartnerSkillUp_Enable a Streaming CDC Solution
Timothy Spann
 
Percona University - ProxySQL para MySQL
Marcelo Altmann
 
Splunk configuration file for the cloud
willmorekanan
 
SharePoint 2010 Virtualization - SharePoint Saturday L.A.
Michael Noel
 
SharePoint 2010 Virtualization - Norway SharePoint User Group
Michael Noel
 
Minikube – get Connections in the smalles possible setup
Martin Schmidt
 
CCCEU15 run cloudstack in docker
Pierre-Luc Dion
 
CloudStack Collab Conference 2015 Run CloudStack in Docker
CloudOps2005
 
Mueller bacdjuly2012privatepaaswithstackato-120712154134-phpapp01
Accenture
 
High available BizTalk infrastructure on Azure IaaS
BizTalk360
 
vBACD July 2012 - Deploying Private PaaS with ActiveState Stackato
CloudStack - Open Source Cloud Computing Project
 
Curso de MySQL 5.7
Eduardo Legatti
 
Ad

More from Alkin Tezuysal (15)

PDF
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
PDF
Unified Observability - Alkin Tezuysal - FOSSASIA Summit March 2025 .pdf
Alkin Tezuysal
 
PDF
Boosting MySQL with Vector Search Scale22X 2025.pdf
Alkin Tezuysal
 
PDF
Boosting MySQL with Vector Search Fosdem 2025.pdf
Alkin Tezuysal
 
PDF
London MySQL Day - Lightning Talk Dec 2024.pdf
Alkin Tezuysal
 
PDF
Design and Modeling with MySQL and PostgreSQL - Percona University Istanbul S...
Alkin Tezuysal
 
PDF
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Alkin Tezuysal
 
PPTX
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Alkin Tezuysal
 
PDF
FOSSASIA - MySQL Cookbook 4e Journey APR 2023.pdf
Alkin Tezuysal
 
PDF
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
Alkin Tezuysal
 
PDF
How OLTP to OLAP Archival Demystified
Alkin Tezuysal
 
PDF
MySQL Cookbook: Recipes for Developers, Alkin Tezuysal and Sveta Smirnova - P...
Alkin Tezuysal
 
PDF
My first 90 days with ClickHouse.pdf
Alkin Tezuysal
 
PPTX
When is MyRocks good?
Alkin Tezuysal
 
PDF
PXC (Xtradb) Failure and Recovery
Alkin Tezuysal
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Unified Observability - Alkin Tezuysal - FOSSASIA Summit March 2025 .pdf
Alkin Tezuysal
 
Boosting MySQL with Vector Search Scale22X 2025.pdf
Alkin Tezuysal
 
Boosting MySQL with Vector Search Fosdem 2025.pdf
Alkin Tezuysal
 
London MySQL Day - Lightning Talk Dec 2024.pdf
Alkin Tezuysal
 
Design and Modeling with MySQL and PostgreSQL - Percona University Istanbul S...
Alkin Tezuysal
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Alkin Tezuysal
 
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Alkin Tezuysal
 
FOSSASIA - MySQL Cookbook 4e Journey APR 2023.pdf
Alkin Tezuysal
 
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
Alkin Tezuysal
 
How OLTP to OLAP Archival Demystified
Alkin Tezuysal
 
MySQL Cookbook: Recipes for Developers, Alkin Tezuysal and Sveta Smirnova - P...
Alkin Tezuysal
 
My first 90 days with ClickHouse.pdf
Alkin Tezuysal
 
When is MyRocks good?
Alkin Tezuysal
 
PXC (Xtradb) Failure and Recovery
Alkin Tezuysal
 
Ad

Recently uploaded (20)

PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Designing Production-Ready AI Agents
Kunal Rai
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
July Patch Tuesday
Ivanti
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 

Introduction to Vitess on Kubernetes for MySQL - Webinar

  • 1. Introduction to Vitess on Kubernetes for MySQL Alkin Tezuysal - Sr. Technical Manager, Percona Sugu Sougoumarane - CTO/Co-Founder, PlanetScale 2020 Webinar Series - May 11th 2020
  • 2. © 2020 Percona Who are we? Sr. Technical Manager at Percona Open Source Database Evangelist Global Database Operations Expert Inspiring Technical and Strategic Leader Creative Team Builder Speaker, Mentor, and Coach Co-creator of Vitess, CTO at PlanetScale. Scalability at YouTube, PayPal in the early days. Argues about distributed systems and consensus algorithms. Occasionally blogs at ssougou.blogspot.com. 2 Alkin Tezuysal - @ask_dba Born to Sail, Forced to Work Sugu Sougoumarane - @ssougou Storage Geek @@ask_dba, @ssougou
  • 3. © 2020 Percona A Database Clustering System for Horizontal Scaling of MySQL 3 @@ask_dba, @ssougou
  • 4. © 2020 Percona Introduction to Vitess 4 @@ask_dba, @ssougou
  • 5. © 2020 Percona Vitess in CNCF (Cloud Native Computing Foundation) 5 @@ask_dba, @ssougou
  • 6. © 2020 Percona True Multi-Cloud Clusters for PlanetScaleDB 6 @@ask_dba, @ssougou
  • 7. © 2020 Percona Kubernetes on Google Cloud (GKE) ● Google Cloud's load-balancing for Compute Engine instances ● Node pools to designate subsets of nodes within a cluster for additional flexibility ● Automatic scaling of your cluster's node instance count ● Automatic upgrades for your cluster's node software ● Node auto-repair to maintain node health and availability ● Logging and monitoring with Google Cloud's operations suite for visibility into your cluster 7 @@ask_dba, @ssougou
  • 8. © 2020 Percona Installation and Configuration ● Vitess on Google Cloud Platform Prerequisites ○ Google Kubernetes Engine (GKE) ○ Cluster with 7 nodes ○ K8s Version 1.15.11-gke.1 ○ Helm Version 3 ● Requirements ○ RBR ○ GTID ○ MySQL 5.6+ MariaDB 10.x+ 8 @@ask_dba, @ssougou
  • 9. © 2020 Percona Create Vitess Cluster GKE 9 @@ask_dba, @ssougou
  • 10. © 2020 Percona Setup Basics 10 @@ask_dba, @ssougou
  • 12. © 2020 Percona Connect to K8s Cluster 12 @@ask_dba, @ssougou
  • 13. © 2020 Percona Download and install Helm 3.X $ wget https://get.helm.sh/helm-v3.1.2-linux-amd64.tar.gz $ tar xvfz helm-v3.1.2-linux-amd64.tar.gz $ sudo cp linux-amd64/helm /usr/local/bin/helm $ go get vitess.io/vitess/go/cmd/vtctlclient $ git clone [email protected]:vitessio/vitess.git $ cd vitess/examples/helm 13 @@ask_dba, @ssougou
  • 14. © 2020 Percona Install Vitess $ helm install vitess ../../helm/vitess -f 101_initial_cluster.yaml NAME: vitess LAST DEPLOYED: Thu May 7 13:55:49 2020 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: Release name: vitess To access administrative web pages, start a proxy with: kubectl proxy --port=8001 Then use the following URLs: vtctld: http://localhost:8001/api/v1/namespaces/default/services/vtctld:web/proxy/app/ vtgate: http://localhost:8001/api/v1/namespaces/default/services/vtgate-zone1:web/proxy/ 14 @@ask_dba, @ssougou
  • 15. © 2020 Percona Run Proxy and access to Web Portal(s) To access administrative web pages, start a proxy with: kubectl proxy --port=8001 Then use the following URLs: vtctld: http://localhost:8001/api/v1/namespaces/default/services/vtctld:web/proxy/app/ vtgate: http://localhost:8001/api/v1/namespaces/default/services/vtgate-zone1:web/proxy/ 15 @@ask_dba, @ssougou
  • 16. © 2020 Percona Vitess Control Panel 16 @@ask_dba, @ssougou
  • 17. © 2020 Percona vtgate status dashboard 17 @@ask_dba, @ssougou
  • 18. © 2020 Percona kubectl status $ kubectl get pods,jobs NAME READY STATUS RESTARTS AGE pod/commerce-apply-schema-initial-z27sm 0/1 Completed 0 14m pod/commerce-apply-vschema-initial-292nc 0/1 Completed 0 14m pod/vtctld-c56d6c788-t9xlc 1/1 Running 0 14m pod/vtgate-zone1-7d4957f6-49xsr 1/1 Running 0 14m pod/zone1-commerce-0-init-shard-master-69fbc 0/1 Completed 0 14m pod/zone1-commerce-0-replica-0 6/6 Running 0 14m pod/zone1-commerce-0-replica-1 6/6 Running 0 14m pod/zone1-commerce-0-replica-2 6/6 Running 0 14m NAME COMPLETIONS DURATION AGE job.batch/commerce-apply-schema-initial 1/1 59s 14m job.batch/commerce-apply-vschema-initial 1/1 62s 14m job.batch/zone1-commerce-0-init-shard-master 1/1 57s 14m 18 @@ask_dba, @ssougou
  • 19. © 2020 Percona Port-forwarding kubectl port-forward service/vtctld 15000 15999 & process_id1=$! kubectl port-forward service/vtgate-zone1 15306:3306 15001 & process_id2=$! sleep 2 echo "You may point your browser to http://localhost:15000 for vtctld." echo "You may point your browser to http://localhost:15001 for vtgate, use the following aliases as shortcuts:" echo 'alias vtctlclient="vtctlclient -server=localhost:15999"' echo 'alias mysql="mysql -h 127.0.0.1 -P 15306"' echo "Hit Ctrl-C to stop the port forwards" wait $process_id1 wait $process_id2 19 @@ask_dba, @ssougou
  • 20. © 2020 Percona Connect to MySQL $ mysql Handling connection for 15306 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 7 Server version: 5.7.9-Vitess Percona Server (GPL), Release 29, Revision 11ad961 Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> show databases; +-----------+ | Databases | +-----------+ | commerce | +-----------+ 1 row in set (0.11 sec) 20 @@ask_dba, @ssougou
  • 21. © 2020 Percona Creating a Keyspace mysql> show tables; +--------------------+ | Tables_in_commerce | +--------------------+ | corder | | customer | | product | +--------------------+ 3 rows in set (0.11 sec) $ mysql < ./vitess/examples/common/insert_commerce_data.sql 21 @@ask_dba, @ssougou
  • 22. © 2020 Percona Verify data mysql> select * from corder; select * from customer; select * from product; +----------+-------------+----------+-------+ | order_id | customer_id | sku | price | +----------+-------------+----------+-------+ | 1 | 1 | SKU-1001 | 100 | | 2 | 2 | SKU-1002 | 30 | | 3 | 3 | SKU-1002 | 30 | | 4 | 4 | SKU-1002 | 30 | | 5 | 5 | SKU-1002 | 30 | +----------+-------------+----------+-------+ 5 rows in set (0.11 sec) 22 @@ask_dba, @ssougou
  • 23. © 2020 Percona Verify data +-------------+--------------------+ | customer_id | email | +-------------+--------------------+ | 1 | [email protected] | | 2 | [email protected] | | 3 | [email protected] | | 4 | [email protected] | | 5 | [email protected] | +-------------+--------------------+ 5 rows in set (0.11 sec) +----------+-------------+-------+ | sku | description | price | +----------+-------------+-------+ | SKU-1001 | Monitor | 100 | | SKU-1002 | Keyboard | 30 | +----------+-------------+-------+ 2 rows in set (0.11 sec) 23 @@ask_dba, @ssougou
  • 24. © 2020 Percona Similarities and Differences Similarities ● If Vitess was treated as MySQL Server, a Keyspace would be a database. ● A Keyspace can have one or many shards ● Each Shard is one MySQL cluster: master+replicas Differences ● If a table name is unique across all keyspaces, it can be accessed without the qualifying it with db name ● You can “use `keyspace@master`” or “use `keyspace@replica`” ● Bypass shard routing with “use `keyspace:-80@master`” 24 @@ask_dba, @ssougou
  • 25. © 2020 Percona Moving Tables Use case Customer load is increasing, MySQL is reaching its limits. We want to move the customer and corder tables to a separate MySQL cluster, aka “unsharded keyspace”. 25 @@ask_dba, @ssougou
  • 26. © 2020 Percona Create customer keyspace keyspaces: - name: "commerce" shards: - name: "0" tablets: - type: "replica" vttablet: replicas: 3 - name: "customer" shards: - name: "0" tablets: - type: "replica" vttablet: replicas: 3 26 @@ask_dba, @ssougou
  • 27. © 2020 Percona Bring up customer keyspace $ helm upgrade vitess ../../helm/vitess/ -f 201_customer_tablets.yaml Release "vitess" has been upgraded. Happy Helming! NAME: vitess LAST DEPLOYED: Sun May 10 14:21:14 2020 NAMESPACE: default STATUS: deployed REVISION: 2 TEST SUITE: None NOTES: Release name: vitess To access administrative web pages, start a proxy with: kubectl proxy --port=8001 Then use the following URLs: vtctld: http://localhost:8001/api/v1/namespaces/default/services/vtctld:web/proxy/app/ vtgate: http://localhost:8001/api/v1/namespaces/default/services/vtgate-zone1:web/proxy/ a 27 @@ask_dba, @ssougou
  • 28. © 2020 Percona Verify upgrade zone1-customer-0-replica-0 2/2 Running 0 108s zone1-customer-0-replica-1 2/2 Running 0 108s zone1-customer-0-replica-2 2/2 Running 0 108s mysql> show databases; +-----------+ | Databases | +-----------+ | commerce | | customer | +-----------+ 2 rows in set (0.04 sec) 28 @@ask_dba, @ssougou
  • 29. © 2020 Percona Initiate move tables $ vtctlclient MoveTables -workflow=commerce2customer commerce customer '{"customer":{}, "corder":{}}' 29 @@ask_dba, @ssougou
  • 30. © 2020 Percona Sanity check mysql> use commerce:0 mysql> select count(*) from corder; +----------+ | count(*) | +----------+ | 5 | +----------+ mysql> use customer:0 mysql> select count(*) from corder; +----------+ | count(*) | +----------+ | 5 | +----------+ 30 @@ask_dba, @ssougou
  • 31. © 2020 Percona VDiff ~/...vitess/examples/helm> vtctlclient VDiff customer.commerce2customer Summary for corder: {ProcessedRows:5 MatchingRows:5 MismatchedRows:0 ExtraRowsSource:0 ExtraRowsTarget:0} Summary for customer: {ProcessedRows:5 MatchingRows:5 MismatchedRows:0 ExtraRowsSource:0 ExtraRowsTarget:0} 31 @@ask_dba, @ssougou
  • 32. © 2020 Percona Switch Traffic $ vtctlclient SwitchReads -tablet_type=rdonly customer.commerce2customer $ vtctlclient SwitchReads -tablet_type=replica customer.commerce2customer $ vtctlclient SwitchWrites customer.commerce2customer 32 @@ask_dba, @ssougou
  • 33. © 2020 Percona Clean-up $ vtctlclient DropSources customer.commerce2customer 33 @@ask_dba, @ssougou
  • 34. © 2020 Percona Reshard Use case Traffic has continued to grow, but the corder table is getting too big to fit in a single database. There is a relationship between corder and customer. It will be beneficial to co-locate every orders with their customer rows. Auto-inc won’t work. Solution: Vitess Sequences. 34 @@ask_dba, @ssougou
  • 35. © 2020 Percona Creating sequences 301_customer_sharded.yaml (commerce schema) create table customer_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence'; insert into customer_seq(id, next_id, cache) values(0, 1000, 100); create table order_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence'; insert into order_seq(id, next_id, cache) values(0, 1000, 100); 35 @@ask_dba, @ssougou
  • 36. © 2020 Percona Creating sequences 301_customer_sharded.yaml (customer VSchema) { "tables": { "customer_seq": { "type": "sequence" }, "order_seq": { "type": "sequence" }, "product": {} } } 36 @@ask_dba, @ssougou
  • 37. © 2020 Percona 301_customer_sharded.yaml (commerce VSchema) { "sharded": true, "vindexes": { "hash": { "type": "hash" } }, "tables": { "customer": { "column_vindexes": [ { "column": "customer_id", ... "corder": { "column_vindexes": [ { "column": "customer_id", "name": "hash" } ], "auto_increment": { "column": "order_id", "sequence": "order_seq" } } } } Primary Vindexes, aka Sharding Keys 37 @@ask_dba, @ssougou
  • 38. © 2020 Percona Apply Changes $ helm upgrade vitess ../../helm/vitess/ -f 301_customer_sharded.yaml 38 @@ask_dba, @ssougou
  • 39. © 2020 Percona - name: "customer" shards: - name: "0" tablets: - type: "replica" vttablet: replicas: 3 - name: "-80" tablets: - type: "replica" vttablet: replicas: 3 copySchema: source: "customer/0" - name: "80-" tablets: - type: "replica" vttablet: replicas: 3 copySchema: source: "customer/0" Create Target Shards 39 @@ask_dba, @ssougou
  • 40. © 2020 Percona Apply Changes $ helm upgrade vitess ../../helm/vitess/ -f 302_new_shards.yaml 40 @@ask_dba, @ssougou
  • 41. © 2020 Percona Verify cluster zone1-customer-80-x-replica-0 2/2 Running 0 115s zone1-customer-80-x-replica-1 2/2 Running 0 115s zone1-customer-80-x-replica-2 2/2 Running 0 115s zone1-customer-x-80-init-shard-master-6zhhn 0/1 Completed 0 114s zone1-customer-x-80-replica-0 2/2 Running 0 114s zone1-customer-x-80-replica-1 2/2 Running 0 114s zone1-customer-x-80-replica-2 2/2 Running 0 114s 41 @@ask_dba, @ssougou
  • 42. © 2020 Percona Initiate Resharding $ vtctlclient Reshard customer.cust2cust '0' '-80,80-' 42 @@ask_dba, @ssougou
  • 43. © 2020 Percona mysql> use customer:0 mysql> select count(*) from corder; +----------+ | count(*) | +----------+ | 5 | +----------+ mysql> use customer:-80 mysql> select count(*) from corder; +----------+ | count(*) | +----------+ | 4 | +----------+ mysql> use customer:80- mysql> select count(*) from corder; +----------+ | count(*) | +----------+ | 1 | +----------+ Sanity Check 43 @@ask_dba, @ssougou
  • 44. © 2020 Percona VDiff ~/...vitess/examples/helm> vtctlclient VDiff customer.cust2cust Summary for corder: {ProcessedRows:5 MatchingRows:5 MismatchedRows:0 ExtraRowsSource:0 ExtraRowsTarget:0} Summary for customer: {ProcessedRows:5 MatchingRows:5 MismatchedRows:0 ExtraRowsSource:0 ExtraRowsTarget:0} 44 @@ask_dba, @ssougou
  • 45. © 2020 Percona Switch over $ vtctlclient SwitchReads -tablet_type=rdonly customer.cust2cust $ vtctlclient SwitchReads -tablet_type=replica customer.cust2cust $ vtctlclient SwitchWrites customer.cust2cust 45 @@ask_dba, @ssougou
  • 46. © 2020 Percona Down Shard 0 $ helm upgrade vitess ../../helm/vitess/ -f 306_down_shard_0.yaml $ vtctlclient DeleteShard -recursive customer/0 46 @@ask_dba, @ssougou
  • 47. © 2020 Percona Tear-down Cluster $ helm delete vitess $ kubectl delete pvc -l "app=vitess" $ kubectl delete vitesstoponodes --all 47 @@ask_dba, @ssougou
  • 49. @ 2020 Percona Introduction to Vitess on Kubernetes for MySQL - Part I of III Vitess.io PlanetScale Operating Vitess – Square Cloud Native Computing Foundation: Home Page CNCF Cloud Native Interactive Landscape PlanetScaleDB delivers true multi-cloud, multi-region clusters on AWS, GCP, and Azure - Blog Vitess Demo References 49