SlideShare a Scribd company logo
Introducing TiDB/TiKV
Kevin Xu (@kevinsxu; kevin@pingcap.com)
Agenda
● History and Community
● Technical Walkthrough
● Use Case with Mobike
● Q&A
● (Time Permitting) TiDB on Google Kubernetes Engine
A little about me
● General Manager of Global Strategy and
Operations
● Studied CS and Law at Stanford
● Program in Javascript, Python, and
(more recently) learning Rust
A little about PingCAP
● Founded in April 2015 by 3
infrastructure engineers
● Offices throughout North America
and China
PingCAP.com
Recent News
PingCAP.com
Our Product: the TiDB Platform
● TiDB Platform (Ti = Titanium)
○ TiDB (SQL Layer)
○ TiKV (Key-Value Storage)
○ TiSpark (Spark plugin to TiKV)
● Open source from Day 1
○ GA 1.0: October 2017
○ GA 2.0: April 2018
PingCAP.com
Community
Stars
● TiDB: 15,300+
● TiKV: 3,700+
Contributors
● TiDB: 200+
● TiKV: 100+
Common Use Cases
1. MySQL Scalability
2. Hybrid OLTP/OLAP Architecture
3. Unifying Data Storage/Management
TiDB Platform
PingCAP.com
Cloud-Native Architecture
TiDB
TiDB
TiDB
Applicationvia
MySQLProtocol
TiKV
TiKV
TiKV
TiKV
TiKV
TiKV
Worker
Worker
Worker
Spark Driver
... ...
...
SparkSQL
Spark Cluster
PD Cluster
DistSQL
API
KV API
DistSQL
API
PD
PD PD
Metadata
TSO / Data Location
Data Location
PingCAP.com
TiKV (in CNCF): The Storage Foundation
Region 5
Region 1
Region 3
TiKV node 1
Store 1
Region 4
gRPC
Region 1
Region 2
TiKV node 2
Store 2
Region 3
gRPC
Region 3
Region 1
Region 5
TiKV node 3
Store 3
gRPC
Region 5
Region 1
Region 2
TiKV node 4
Store 4
gRPC
Client
PD 1
PD 2
PD 3
Placement
Driver
Raft GroupRegion 4
Region 4
PingCAP.com
TiDB: The (My)SQL Layer
Node1 Node2 Node3 Node4
MySQL Network Protocol
SQL Parser
Cost-based Optimizer
Coprocessor API
ODBC/JDBC MySQL Client
Any ORM which
supports MySQL
TiDB
TiKV
PingCAP.com
SQL -> Parser -> Coprocessor
PingCAP.com
Join Support
● Hash Join (fastest; if table <= 50 million rows)
● Sort Merge Join (join on indexed column or ordered
data source)
● Index Lookup Join (join on indexed column; ideally
after filter, result < 10,000 rows)
● Chosen based on Cost-base Optimizer:
PingCAP.com
TiSpark: Complex OLAP
Spark ExecSpark Exec
Spark Driver
Spark Exec
TiKV TiKV TiKV TiKV
TiSpark
TiSpark TiSpark TiSpark
TiKV
Placement
Driver (PD)
gRPC
Distributed Storage Layer
gRPC
retrieve data location
retrieve real data from TiKV
PingCAP.com
Placement Driver
● Provide a God’s view of
the entire cluster
● Store metadata, balancing
workload, issue
timestamps
● Also a cluster with
embedded etcd
Placement
Driver
Placement
Driver
Placement
Driver
Raft Raft
Raft
PingCAP.com
Transaction Model
● Timestamp Oracle Service (from
Google’s Percolator)
● 2-Phase commit protocol (2PC)
● Problem: Single point of failure
● Solution: PD HA cluster
Placement
Driver
Placement
Driver
Placement
Driver
Raft Raft
Raft
PingCAP.com
TiDB Operator
● Operator pattern inspired by CoreOS...(now Redhat...(now IBM))
● Boostraps TiDB cluster and simplifies/automates:
○ Deployment
○ Scaling
○ Scheduling
○ Auto-Failover
○ Upgrade
● Open Sourced
○ https://github.com/pingcap/tidb-operator
PingCAP.com
TiDB Operator
API ServerController ManagerScheduler
Kubernetes Core
TiDB Controller Manager
TiDB Cluster Controller
PD Controller
TiKV
Controller
TiDB
Controller
TiDB Scheduler:
TiDB Cloud Manager
API Gateway
Control Plane
Cost Controller
Kube Scheduler
TiDB Scheduler
PingCAP.com
Cloud Native Tools
● Prometheus
○ (maintains Rust implementation:
https://github.com/pingcap/rust-prometheus)
● gRPC
○ (maintains Rust implementation: https://github.com/pingcap/grpc-rs)
● etcd
PingCAP.com
TiDB, Managed As A Cloud Service
Early Access: https://www.pingcap.com/tidb-cloud/
Who’s Using TiDB?
PingCAP.com
Who’s Using TiDB?
300+
Companies
Common Use Cases
1. MySQL Scalability
2. Hybrid OLTP/OLAP Architecture
3. Unifying Data Storage/Management
PingCAP.com
Mobike + TiDB
● 200 million users
● 200 cities
● 9 million smart bikes
● ~30 TB / day
PingCAP.com
Scenario #1: Locking/Unlocking
● Locking and unlocking of smart bikes
generates massive data
● Smooth experience is the key to user retention
● TiDB supports this system by alerting
administrators when the success rate of
locking/unlocking drops, within minutes
● Quickly find malfunctioning bikes
PingCAP.com
Scenario #2: Real-Time Analysis
● Synchronize TiDB with MySQL
instances using Syncer
(proprietary tool)
● TiDB + TiSpark empower
real-time analysis with
horizontal scalability
● No need for Hadoop + Hive
PingCAP.com
Scenario #3: Mobike Store
● An innovative loyalty program that
must be on 24x7x365
● TiDB provides:
○ High-concurrency for peak or
promotional season
○ Permanent storage
○ Horizontal scalability
● No interruption as business evolves
PingCAP.com
Thank You!
20% OFF KubeCon:
KCNA18SPR
kevin@pingcap.com
@kevinsxu; @pingcap
TiDB Cloud Early Access:
https://www.pingcap.com/
tidb-cloud/
TiDB Academy Sign-up:
www.pingcap.com/tidb-ac
ademy/
Appendix
PingCAP.com
CBO 101
or:
Imagine we got a logical plan:
Its physical plan could be:
PingCAP.com
CBO 101
Network cost Memory cost CPU cost
In TiDB, the default memory factor is 5 and CPU factor is 0.8.
For example: Operator Sort(r), its cost would be:
TiDB will maintain histogram of data
PingCAP.com
Relational -> KV
ID Name Email
1 Edward h@pingcap.com
2 Tom tom@pingcap.com
...
user/1 Edward,h@pingcap.com
user/2 Tom,tom@pingcap.com
...
In TiKV -∞
+∞
(-∞, +∞)
Sorted map
“User” Table
Some region...
PingCAP.com
Index Structure
Row:
Key: tablePrefix_rowPrefix_tableID_rowID (IDs are assigned by TiDB, all int64)
Value: [col1, col2, col3, col4]
Index:
Key: tablePrefix_idxPrefix_tableID_indexID_ColumnsValue_rowID
Value: [null]
Keys are ordered by byte array in TiKV, so can support SCAN
Every key is appended a timestamp, issued by Placement Driver
PingCAP.com
Guaranteeing Correctness
● Formal proof using TLA+
○ a formal specification and verification language to reason about and
prove aspects of complex systems
● Raft
● TSO/Percolator
● 2PC
● See details: https://github.com/pingcap/tla-plus
PingCAP.com
MySQL Compatibility - Summary
● Compatibility with MySQL 5.7
○ Joins, subqueries, DML, DDL
etc.
● On the roadmap:
○ Views, Window Functions
● Missing:
○ Stored Procedures, Triggers,
Events, Fulltext
pingcap.com
/docs/sql/mysql-compatibility/
PingCAP.com
MySQL Compatibility - Nuanced
● Some features work differently
○ Auto Increment
○ Optimistic Locking
● TiDB works better with smaller
transactions
○ Recommended to batch
updates, deletes, inserts to
5000 rows
pingcap.com
/docs/sql/mysql-compatibility/

More Related Content

What's hot (20)

PDF
Presto Summit 2018 - 10 - Qubole
kbajda
 
PDF
[Paper Reading]Orca: A Modular Query Optimizer Architecture for Big Data
PingCAP
 
PDF
A Brief Introduction of TiDB (Percona Live)
PingCAP
 
PPTX
Building a transactional key-value store that scales to 100+ nodes (percona l...
PingCAP
 
PDF
Rust in TiKV
PingCAP
 
PDF
TiDB DevCon 2020 Opening Keynote
PingCAP
 
PDF
Introducing TiDB - Percona Live Frankfurt
Morgan Tocker
 
PDF
How to build TiDB
PingCAP
 
PDF
Scale Relational Database with NewSQL
PingCAP
 
PDF
Presto Summit 2018 - 04 - Netflix Containers
kbajda
 
PDF
Presto talk @ Global AI conference 2018 Boston
kbajda
 
PDF
Pivotal Greenplum Cloud Marketplaces - Greenplum Summit 2019
VMware Tanzu
 
PDF
Presto Summit 2018 - 09 - Netflix Iceberg
kbajda
 
PDF
Presto Summit 2018 - 07 - Lyft
kbajda
 
PDF
[Paper Reading] Steering Query Optimizers: A Practical Take on Big Data Workl...
PingCAP
 
PDF
[Paper reading] Interleaving with Coroutines: A Practical Approach for Robust...
PingCAP
 
PDF
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
InfluxData
 
PDF
InfluxDB 2.0: Dashboarding 101 by David G. Simmons
InfluxData
 
PPTX
Challenges in Building a Data Pipeline
Manish Kumar
 
PDF
Unifying Frontend and Backend Development with Scala - ScalaCon 2021
Taro L. Saito
 
Presto Summit 2018 - 10 - Qubole
kbajda
 
[Paper Reading]Orca: A Modular Query Optimizer Architecture for Big Data
PingCAP
 
A Brief Introduction of TiDB (Percona Live)
PingCAP
 
Building a transactional key-value store that scales to 100+ nodes (percona l...
PingCAP
 
Rust in TiKV
PingCAP
 
TiDB DevCon 2020 Opening Keynote
PingCAP
 
Introducing TiDB - Percona Live Frankfurt
Morgan Tocker
 
How to build TiDB
PingCAP
 
Scale Relational Database with NewSQL
PingCAP
 
Presto Summit 2018 - 04 - Netflix Containers
kbajda
 
Presto talk @ Global AI conference 2018 Boston
kbajda
 
Pivotal Greenplum Cloud Marketplaces - Greenplum Summit 2019
VMware Tanzu
 
Presto Summit 2018 - 09 - Netflix Iceberg
kbajda
 
Presto Summit 2018 - 07 - Lyft
kbajda
 
[Paper Reading] Steering Query Optimizers: A Practical Take on Big Data Workl...
PingCAP
 
[Paper reading] Interleaving with Coroutines: A Practical Approach for Robust...
PingCAP
 
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
InfluxData
 
InfluxDB 2.0: Dashboarding 101 by David G. Simmons
InfluxData
 
Challenges in Building a Data Pipeline
Manish Kumar
 
Unifying Frontend and Backend Development with Scala - ScalaCon 2021
Taro L. Saito
 

Similar to Presentation at SF Kubernetes Meetup (10/30/18), Introducing TiDB/TiKV (20)

PDF
Introducing TiDB @ SF DevOps Meetup
Kevin Xu
 
PDF
TiDB Introduction - Boston MySQL Meetup Group
Morgan Tocker
 
PDF
TiDB + Mobike by Kevin Xu (@kevinsxu)
Kevin Xu
 
PDF
Introducing TiDB Operator [Cologne, Germany]
Kevin Xu
 
PDF
FOSDEM MySQL and Friends Devroom
Morgan Tocker
 
PDF
Introducing TiDB Operator
Kevin Xu
 
PDF
"Smooth Operator" [Bay Area NewSQL meetup]
Kevin Xu
 
PDF
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Mydbops
 
PDF
Keynote -- Percona Live Europe 2018
Kevin Xu
 
PDF
TiDB vs Aurora.pdf
ssuser3fb50b
 
PDF
When Apache Spark Meets TiDB with Xiaoyu Ma
Databricks
 
PDF
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
Mydbops
 
PDF
TiDB - From Data to Discovery: Exploring the Intersection of Distributed Dat...
Mydbops
 
PDF
Purpose-built NoSQL Database for IoT by Basavaraj Soppannavar
Data Con LA
 
PDF
"Hadoop and Data Warehouse (DWH) – Friends, Enemies or Profiteers? What about...
Kai Wähner
 
PDF
Where Does Big Data Meet Big Database - QCon 2012
Ben Stopford
 
PDF
Migration Journey To TiDB - Kabilesh PR - Mydbops MyWebinar 38
Mydbops
 
PDF
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Mydbops
 
PPTX
Column Stores and Google BigQuery
Csaba Toth
 
PPTX
NoSQL for the SQL Server Pro
Lynn Langit
 
Introducing TiDB @ SF DevOps Meetup
Kevin Xu
 
TiDB Introduction - Boston MySQL Meetup Group
Morgan Tocker
 
TiDB + Mobike by Kevin Xu (@kevinsxu)
Kevin Xu
 
Introducing TiDB Operator [Cologne, Germany]
Kevin Xu
 
FOSDEM MySQL and Friends Devroom
Morgan Tocker
 
Introducing TiDB Operator
Kevin Xu
 
"Smooth Operator" [Bay Area NewSQL meetup]
Kevin Xu
 
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Mydbops
 
Keynote -- Percona Live Europe 2018
Kevin Xu
 
TiDB vs Aurora.pdf
ssuser3fb50b
 
When Apache Spark Meets TiDB with Xiaoyu Ma
Databricks
 
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
Mydbops
 
TiDB - From Data to Discovery: Exploring the Intersection of Distributed Dat...
Mydbops
 
Purpose-built NoSQL Database for IoT by Basavaraj Soppannavar
Data Con LA
 
"Hadoop and Data Warehouse (DWH) – Friends, Enemies or Profiteers? What about...
Kai Wähner
 
Where Does Big Data Meet Big Database - QCon 2012
Ben Stopford
 
Migration Journey To TiDB - Kabilesh PR - Mydbops MyWebinar 38
Mydbops
 
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Mydbops
 
Column Stores and Google BigQuery
Csaba Toth
 
NoSQL for the SQL Server Pro
Lynn Langit
 
Ad

Recently uploaded (20)

PPTX
computer forensics encase emager app exp6 1.pptx
ssuser343e92
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PPTX
Quality on Autopilot: Scaling Testing in Uyuni
Oscar Barrios Torrero
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PDF
Transform Retail with Smart Technology: Power Your Growth with Ginesys
Ginesys
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PPTX
ERP - FICO Presentation BY BSL BOKARO STEEL LIMITED.pptx
ravisranjan
 
PPTX
WYSIWYG Web Builder Crack 2025 – Free Download Full Version with License Key
HyperPc soft
 
PPTX
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
EO4EU Ocean Monitoring: Maritime Weather Routing Optimsation Use Case
EO4EU
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
PPTX
Cubase Pro Crack 2025 – Free Download Full Version with Activation Key
HyperPc soft
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
computer forensics encase emager app exp6 1.pptx
ssuser343e92
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Quality on Autopilot: Scaling Testing in Uyuni
Oscar Barrios Torrero
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
Transform Retail with Smart Technology: Power Your Growth with Ginesys
Ginesys
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
ERP - FICO Presentation BY BSL BOKARO STEEL LIMITED.pptx
ravisranjan
 
WYSIWYG Web Builder Crack 2025 – Free Download Full Version with License Key
HyperPc soft
 
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
EO4EU Ocean Monitoring: Maritime Weather Routing Optimsation Use Case
EO4EU
 
Human Resources Information System (HRIS)
Amity University, Patna
 
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
Cubase Pro Crack 2025 – Free Download Full Version with Activation Key
HyperPc soft
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
Ad

Presentation at SF Kubernetes Meetup (10/30/18), Introducing TiDB/TiKV