Distributed MySQL

本周我们很开心邀请到了Christie给我们带来了《Distributed MySQL》的介绍,相关总结如下:

Slides

  1. Christie使用的Slides
  2. MySQL系列讲座第一讲总结:MySQL DB 引擎的演化和对比 && MySQL Query和Schema Migration的介绍
  3. MySQL系列讲座第二讲总结:MySQL存储引擎的深入介绍
  4. MySQL系列讲座第三讲总结:MySQL的事务介绍
  5. MySQL系列讲座第四讲总结:MySQL锁的介绍 && MySQL主从一致,高可用以及如何实现数据不丢失
  6. MySQL系列讲座第五讲总结:MySQL主从一致 && MySQL读写分离实操
  7. MySQL系列讲座第六讲总结:Distributed MySQL
  8. MySQL系列讲座第七讲总结:Uber是如何选择在Postgres和MySQL之间切换的

Q&A

感谢锅锅帮忙整理的笔记。

 有service mesh的话,为什么需要Topology呢?

Topology是用来做application与application之间的service discovery

  1. 【扩展】Service Mesh介绍:我们上次关于service mesh的讲座总结。

How to decode a query? 存在sharding的情况下,怎么解析Query?

Topology会储存shard key,每次query需要提shard key给application以此知道去到哪里取数据。

Topology的具体功能解释:https://vitess.io/docs/11.0/concepts/topology-service/

The topology service exists for several reasons:

  • It enables tablets to coordinate among themselves as a cluster.
  • It enables Vitess to discover tablets, so it knows where to route queries.
  • It stores Vitess configuration provided by the database administrator that is needed by many different servers in the cluster, and that must persist between server restarts.

How does VTGate speak the mysql language? 主讲人提到VTGate speak mysql language, 请问怎么叫speak mysql language?

Connect的时候可以把VTGate当作mysql server来进行沟通,尽管host是VTGate但是可以使用mysql的protocol进行。

官网doc 解释: https://vitess.io/docs/11.0/concepts/vtgate/

“It speaks both the MySQL Protocol and the Vitess gRPC protocol. Thus, your applications can connect to VTGate as if it is a MySQL Server.”

Does Vitness allow cross table querying? Vitness可以跨表查询吗, 比如 table join?

可以的。单点(single node)可以允许存各种各样的表,与正常mysql DB无异。Vitness只是提供了一层additional layer,这样方便做sharding,使得系统更加scalable。“Vitess combines many important MySQL features with the scalability of a NoSQL database. Its built-in sharding features let you grow your database without adding sharding logic to your application.”

If we have multiple tables, but sharding policy is different, how to join? 如果单点的表格使用的是不同的sharding策略,那如何join这两个表?

Metadata 和 shard key 是储存在topology里的, 通过shard key取回data之后,是在VTGate这里进行process和数据整合的 (aggregation and result consolidation).

Is Vitness more suitable for heavy reading or heavy writing? Vitness是更适用于读多写少还是写多读少? 

读多写少,因为这是mysql的特性,如果需求是写多读少的话,可能更适合使用Nosql DB。

More read than write. Mysql characteristic. Otherwise it might be better to use Nosql DB.

这里的核心问题不是读多还是写多。Vitness解决的关键问题是mysql 不能像nosql 那么容易scale的问题。而vitness本身还是构建于mysql 架构上的,于是继承了所有mysql的特性。

Core problem vitness is not dealing with more read or more write, but make mysql more scalable.

这里有听众简单对比了一下Mysql和Nosql:

  • 如果是structure data, 有很多query,那么适合使用mysql。
  • Nosql相对难以处理大量的query,因为需要partition key来process,否则每次处理的时候都是全表扫描(global table scan)。
  • 同时提到,一些nosql 正在被淘汰,“Dynamo and cassandra is being deprecated”。不过详细讨论之后得到的结论是淘汰的应该是leaderless的Nosql
  • HBase: single leader
  • Redis cluster:  leaderless

What’s the difference between shard and replica? Shard 和replica的区别是什么?

  • 每个Sharding其实本身更像是一个不同的DB,储存的是不同的数据
    Sharding sections are more like different DB
  • Replica是相同数据存了多份,存在每个sharding里面
    Replica are same DB in shardings
    Replica的作用是:
    • 确保系统没有单点故障
      Make sure master don’t have single point failure
    • 使得读写可以分离,但是这样就需要数据之间的同步
      Read/write can be separate, but hence need sync

Why need VTtablet? 为什么需要VTtablet这一层,直接接入mysql不可以吗?

  • (主讲人) Query 可能会对mysql DB造成损害, 增加一层VTTablet 作为保护
  • (听众) VTtablet 和mysql分开是为了功能性区分这两个模块,更方便debug

再次感谢大家的参与,也希望大家有好的资源能联系我更新这篇文章。谢谢大家。

下周话题安排和往期话题回顾敬请参见《系统设计开荒小分队话题讨论简介

You may also like...

5 Responses

  1. March 24, 2022

    […] MySQL系列讲座第六讲总结:Distributed MySQL […]

  2. March 24, 2022

    […] MySQL系列讲座第六讲总结:Distributed MySQL […]

  3. March 24, 2022

    […] MySQL系列讲座第六讲总结:Distributed MySQL […]

  4. March 24, 2022

    […] MySQL系列讲座第六讲总结:Distributed MySQL […]

  5. April 5, 2022

    […] MySQL系列讲座第六讲总结:Distributed MySQL […]

Leave a Reply

Your email address will not be published.