using rust to build a distributed transactional key value
play

Using Rust to Build a Distributed Transactional Key-Value Database - PowerPoint PPT Presentation

Using Rust to Build a Distributed Transactional Key-Value Database LiuTang | tl@pingcap.com About me Chief Architect at PingCAP TiDB and TiKV Open source projects LedisDB go-mysql go-mysql-elasticsearch


  1. Using Rust to Build a Distributed Transactional Key-Value Database LiuTang | tl@pingcap.com

  2. About me ● Chief Architect at PingCAP ● TiDB and TiKV ● Open source projects ○ LedisDB ○ go-mysql ○ go-mysql-elasticsearch ○ rust-prometheus ○ ...

  3. Agenda ● Introduction ● Hierarchy ○ Storage ○ Raft ○ Transaction ○ RPC Framework ○ Monitor ○ Test ● Combine them all

  4. When we want to build a distributed transactional key-value database...

  5. Consistency Performance Scalability � Stability ACID HA Others…

  6. A High Building, A Low Foundation

  7. Language

  8. Let’s start from scratch!!!

  9. RocksDB Immutable Memory WAL Memory Table Table Flush Memory Disk Compaction SST Info Log Level 0 Manifest SST SST …... SST Level 1 Current SST SST …... SST Level 2

  10. https://github.com/pingcap/rust-rocksdb

  11. Raft Client State State State Machine Machine Machine Raft Raft Raft Module Module Module a = 1 a = 1 a = 1 b = 2 b = 2 b = 2 Log Log Log a = 1 b = 2 a = 1 b = 2 a = 1 b = 2

  12. Multi-Raft Key Space A - B Raft Group Region 1 Region 1 Region 1 Raft Group Region 2 Region 2 Region 2 B - C Raft Group Region 3 Region 3 Region 3 C - D

  13. Multi-Raft - Scalability A B C D Region 1 Region 1 Region 1 Region 2 Region 2 Region 2

  14. Multi-Raft - Scalability A B C D Region 1 Region 1 Region 1 Region 2 Region 2 Region 2 Region 2 Raft ConfChange - AddNode

  15. Multi-Raft - Scalability A B C D Region 1 Region 1 Region 1 Region 2 Region 2 Region 2 Raft ConfChange - RemoveNode

  16. https://github.com/pingcap/raft-rs

  17. Transaction

  18. Transaction How to keep consistency crossing multi-Raft Groups? let mut txn = store.begin() let value1 = txn.get(region1_key) let value2 = txn.get(region2_key) // do something with value txn.set(region1_key, new_value1) txn.set(region2_key, new_value2) txn.commit() // or txn.rollback()

  19. Transaction 1. Inspired by Google Percolator 2. Optimized Two Phase Commit (2 PC) 3. Multiversion Concurrency Control (MVCC) 4. Snapshot Isolation 5. Optimistic Transaction

  20. gRPC ● Mode ○ Unary ○ Client streaming ○ Server streaming ○ Duplex streaming ● Using Futures to wrap the asynchronous C gRPC API let f = unary(service, method, request); let resp = f.wait();

  21. https://github.com/pingcap/grpc-rs

  22. Prometheus ● Type ○ Counter ○ Gauge ○ Histogram lazy_static! { static ref HTTP_COUNTER: Counter = register_counter!( "http_request_total", "Total number of HTTP request." ).unwrap(); } HTTP_COUNTER.inc();

  23. https://github.com/pingcap/rust-prometheus

  24. Testing

  25. Testing - Failure Injection // Ingest a failure fn function_foo() { fail_point!("foo"); } // Run and Trigger the failure FAILPOINTS=foo=panic cargo run

  26. https://github.com/pingcap/fail-rs

  27. Architecture

  28. Architecture Prometheus Client gRPC Txn API Txn API Txn API MVCC MVCC MVCC Raft Raft Raft RocksDB RocksDB RocksDB

  29. https://github.com/pingcap/tikv

  30. Beyond TiKV

  31. A Distributed Relational Database

  32. TiDB Applications MySQL Drivers(e.g. JDBC) MySQL Protocol TiDB RPC TiKV

  33. A Distributed Analytical Database

  34. TiSpark Spark Driver Job Spark Cluster Worker Worker Worker RPC TiKV

  35. Hybrid Transactional/Analytical Processing Database

  36. PD PD Data location TSO/Data location PD PD Cluster Meta data Spark Driver TiDB TiKV TiKV Job API TiDB API Worker TiKV TiDB TiKV Worker TiDB TiKV Worker TiKV ... TiDB ... Spark Cluster ... TiDB Cluster TiKV Cluster (Storage) TiSpark

  37. Thank you! https://github.com/pingcap/tidb https://github.com/pingcap/tikv We are hiring… @China @Silicon Valley @Home

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend