--- tags: IT, Database disqus: kywk-moco --- [DB] 分散式資料庫, SQL middleware and NewSQL ========================================== 分散式資料庫 ---------- 傳統系統架構模式為應用程式直接存取資料庫, 這樣的架構特點是直覺方便. 但隨著資料量不斷增大, 會遇到一些問題: - 單個表格資料量太大 - 單個資料庫資料量太大 - 單個資料庫伺服器壓力太大 - 讀寫速度遇到瓶頸 - ... 遇到上述問題時, 增加硬體效能垂直擴展可已解決眼前的問題. ### MySQL 中間層 ### 不過當業務量不斷累積, 同樣的問題會不斷重現, 而硬體規格是有極限的. 此時只能採用水平擴展的方式來平行化服務負載. 增加新的機器, 把資料庫放在不同機器上, 在應用程式和資料庫之間加一個 Proxy 進行路由管理. 這個 Proxy 即為 MySQL 中間層. - Ex: Vitess (Youtube) / MySQL Proxy / MaxScale / ... ### NewSQL ### RDS (SQL) with ACID guarantees, and NoSQL-like scalable performance for OLTP workloads. - 無關係資料庫的實作方式, 同時間有 NoSQL 資料庫的性能與可擴充性, 並確保事務性需求 (ACID) - 專注於處理 OLTP 類型的數據需求, OLAP 不是 NewSQL 主要解決的問題. - Ex: Google Spanner / CockroachDB / TiDB / VoltDB / MemSQL /AWS Aurora / ... ## [Vitess](https://vitess.io/) ## ### Introduction ### Vitess is a database clustering system for horizontal scaling of MySQL through generalized sharding. ### Features ### #### [2PC](https://vitess.io/docs/launching/twopc/) #### Provide a mechanism to support atomic commits for distributed transactions across multiple Vitess databases. Transactions should either complete successfully or rollback completely. 2PC introduced the prepare protocol to defend against the above three. A database that acknowledges a prepare must give you the following guarantees: 1. It will not abort a transaction unless requested. 2. It will never refuse a commit. 3. If the database crashes, it will reinstate the transaction to its prepared state upon recovery. 2PC transactions guarantee atomicity: either the whole transaction commits, or it’s rolled back entirely. It does not guarantee Isolation (in the ACID sense). Guaranteeing ACID Isolation is very contentious and has high costs. Providing it by default would have made vitess impractical for the most common use cases. ## [TiDB](https://pingcap.com/index.html) ## TiDB is an open-source, cloud-native, MySQL-compatible distributed database that handles hybrid transactional and analytical processing (HTAP) workloads. ## Reference ## __MySQL 中間層__ - [MySQL Sharding Models for SaaS Applications - Percona Database Performance Blog](https://goo.gl/HMhXn2) - SQL 中間層 - [mysql分布式数据库中间件对比 - moonpure的专栏 - CSDN博客](https://goo.gl/8tkFK9) - [mysql中间件研究( Atlas,cobar,TDDL,mycat,heisenberg,Oceanus,vitess,OneProxy ) - __kingzone__的专栏 - CSDN博客](https://goo.gl/H4XCJb) - [Rise of Globally Distributed SQL Databases - Redefining Transactional Stores for Cloud Native Era - The YugaByte Database Blog](https://goo.gl/HDQR78) - [MySQL Router](https://dev.mysql.com/doc/mysql-router/8.0/en/) - [使用MySQL Router实现高可用、负载均衡、读写分离 - wzy0623的专栏 - CSDN博客](https://goo.gl/yKnJCT) - [轻量级中间件MySQL Router介绍与性能测试 - zhao9tian的专栏 - CSDN博客](https://goo.gl/sz7hqJ) - [MySQL Group Replication — 實現應用層HA:MySQL Router – Nito Teng – Medium](https://goo.gl/2cpmHH) __Vitess__ - [The Vitess Docs | Overview](https://vitess.io/docs/overview/) - [Database Cluster | Vitess MySQL | Kubernetes MySQL Cluster](https://goo.gl/Q3BZTt) - [深入理解开源数据库中间件 Vitess:核心特性以及如何进行数据存储的堆叠 - Defonds 的专栏 - CSDN博客](https://goo.gl/ZqVPqn) - [Kubernetes助力CNCF Vitess实现MySQL扩展 - Docker的专栏 - CSDN博客](https://goo.gl/N3rzXv) - [2PC](https://vitess.io/docs/launching/twopc/) - [Design doc: 2PC in Vitess](https://goo.gl/A6Seje) - [Two Phase Commit](https://goo.gl/VqGKAK) - [Distributed Transactions in Vitess · Sweetcode.io](https://goo.gl/Q23Vq9) __TiDB__ - [新一代数据库TiDB在美团的实践 - 美团技术团队](https://goo.gl/qDsdav) - [TiDB 的正确使用姿势 - NewSQL 数据库 TiDB - SegmentFault 思否](https://goo.gl/MCTNur) - [浅析NewSQL数据库——TiDB - 掘金](https://goo.gl/djP2Tm) - [How TiDB Combines OLTP and OLAP in a Distributed Database - DZone Database](https://goo.gl/FGAjVN) - [Performance comparison between TiDB and Vitess · Issue #7160 · pingcap/tidb] - Case study - [PingCAP如何用TiDB解决分布式数据库水平扩展难题](https://goo.gl/C4GYNH) - [分布式数据库TiDB在商业银行的设计与实践 - 51CTO.COM](https://goo.gl/daumbN) - [TiDB 在小米的应用实践 - 知乎](https://goo.gl/4ESe6d) (https://goo.gl/hUW459) - [TiDB 的后花园 - 知乎](https://zhuanlan.zhihu.com/newsql) __Misc__ - [Facebook 開源的分散式有順序資料儲存系統 LogDevice | Tsung's Blog](https://goo.gl/ihzGWs)