Skip to content

Commit

Permalink
tiflash: add mpp glossary and diagram (#15076)
Browse files Browse the repository at this point in the history
  • Loading branch information
hfxsd authored Oct 20, 2023
1 parent 4622f03 commit 65abc6a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
6 changes: 6 additions & 0 deletions glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ Coalesce Partition 是一种减少 Hash 分区表或 Key 分区表中分区数

它们分别对应 [Peer](#regionpeerraft-group) 的三种角色。其中 Leader 负责响应客户端的读写请求;Follower 被动地从 Leader 同步数据,当 Leader 失效时会进行选举产生新的 Leader;Learner 是一种特殊的角色,它只参与同步 raft log 而不参与投票,在目前的实现中只短暂存在于添加副本的中间步骤。

## M

### MPP

从 v5.0 起,TiDB 通过 TiFlash 节点引入了 Massively Parallel Processing (MPP) 架构。这使得大型表连接类查询可以由不同 TiFlash 节点共同分担完成。当 MPP 模式开启后,TiDB 将会根据代价决定是否应该交由 MPP 框架进行计算。MPP 模式下,表连接将通过对 JOIN Key 进行数据计算时重分布(Exchange 操作)的方式把计算压力分摊到各个 TiFlash 执行节点,从而达到加速计算的目的。更多信息请参见 [使用 MPP 模式](/tiflash/use-tiflash-mpp-mode.md)

## O

### Old value
Expand Down
Binary file added media/tiflash/tiflash-mpp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 32 additions & 30 deletions schedule-replicas-by-topology-labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pd-ctl config set isolation-level zone

如果使用 TiUP 部署集群,可以在[初始化配置文件](/production-deployment-using-tiup.md#第-3-步初始化集群拓扑文件)中统一进行 location 相关配置。TiUP 会负责在部署时生成对应的 TiKV、PD 和 TiFlash 配置文件。

下面的例子定义了 `zone``host` 两层拓扑结构。集群的 TiKV 和 TiFlash 分布在三个 zone,z1、z2 和 z3。每个 zone 内有四台主机,z1 两台主机分别部署两个 TiKV 实例,另外两台分别部署一个 TiFlash 实例,z2 和 z3 其中两台主机分别部署一个 TiKV 实例,另外两台分别部署一个 TiFlash 实例。以下例子中 `tikv-n` 代表第 n 个 TiKV 节点的 IP 地址,`tiflash-n` 代表第 n 个 TiFlash 节点的 IP 地址。
下面的例子定义了 `zone``host` 两层拓扑结构。集群的 TiKV 和 TiFlash 分布在三个 zone,z1、z2 和 z3。每个 zone 内有两台主机部署 TiKV,z1 每台主机同时部署两个 TiKV 实例,z2 和 z3 每台主机分别独立部署一个 TiKV 实例。每个 zone 内有两台主机部署 TiFlash,TiFlash 实例均为独占机器部署。以下例子中 `tikv-host-machine-n` 代表第 n 个 TiKV 节点的 IP 地址,`tiflash-host-machine-n` 代表第 n 个 TiFlash 节点的 IP 地址。

```
server_configs:
Expand All @@ -145,87 +145,89 @@ server_configs:
tikv_servers:
# z1
- host: tikv-1
# machine-1 on z1
- host: tikv-host-machine-1
port:20160
config:
server.labels:
zone: z1
host: h1
- host: tikv-1
port:20161
host: tikv-host-machine-1
- host: tikv-host-machine-1
port:20161
config:
server.labels:
zone: z1
host: h1
- host: tikv-2
host: tikv-host-machine-1
# machine-2 on z1
- host: tikv-host-machine-2
port:20160
config:
server.labels:
zone: z1
host: h2
- host: tikv-2
host: tikv-host-machine-2
- host: tikv-host-machine-2
port:20161
config:
server.labels:
zone: z1
host: h2
host: tikv-host-machine-2
# z2
- host: tikv-5
- host: tikv-host-machine-3
config:
server.labels:
zone: z2
host: h1
- host: tikv-6
host: tikv-host-machine-3
- host: tikv-host-machine-4
config:
server.labels:
zone: z2
host: h2
host: tikv-host-machine-4
# z3
- host: tikv-7
- host: tikv-host-machine-5
config:
server.labels:
zone: z3
host: h1
- host: tikv-8
host: tikv-host-machine-5
- host: tikv-host-machine-6
config:
server.labels:
zone: z3
host: h2
host: tikv-host-machine-6
tiflash_servers:
# z1
- host: tiflash-1
- host: tiflash-host-machine-1
learner_config:
server.labels:
zone: z1
host: h3
- host: tiflash-2
host: tiflash-host-machine-1
- host: tiflash-host-machine-2
learner_config:
server.labels:
zone: z1
host: h4
host: tiflash-host-machine-2
# z2
- host: tiflash-3
- host: tiflash-host-machine-3
learner_config:
server.labels:
zone: z2
host: h3
- host: tiflash-4
host: tiflash-host-machine-3
- host: tiflash-host-machine-4
learner_config:
server.labels:
zone: z2
host: h4
host: tiflash-host-machine-4
# z3
- host: tiflash-5
- host: tiflash-host-machine-5
learner_config:
server.labels:
zone: z3
host: h3
- host: tiflash-6
host: tiflash-host-machine-5
- host: tiflash-host-machine-6
learner_config:
server.labels:
zone: z3
host: h4
host: tiflash-host-machine-6
```

详情参阅 [TiUP 跨数据中心部署拓扑](/geo-distributed-deployment-topology.md)
Expand Down
6 changes: 5 additions & 1 deletion tiflash/use-tiflash-mpp-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ summary: 了解如何使用 MPP 模式。

# 使用 MPP 模式

本文档介绍 TiFlash 的 MPP 模式及其使用方法。
本文档介绍 TiFlash 的 [Massively Parallel Processing (MPP)](/glossary.md#mpp) 模式及其使用方法。

TiFlash 支持 MPP 模式的查询执行,即在计算中引入跨节点的数据交换(data shuffle 过程)。TiDB 默认由优化器自动选择是否使用 MPP 模式,你可以通过修改变量 [`tidb_allow_mpp`](/system-variables.md#tidb_allow_mpp-从-v50-版本开始引入)[`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-从-v51-版本开始引入) 的值来更改选择策略。

MPP 模式的工作原理见下图。

![mpp-mode](/media/tiflash/tiflash-mpp.png)

## 控制是否选择 MPP 模式

变量 `tidb_allow_mpp` 控制 TiDB 能否选择 MPP 模式执行查询。变量 `tidb_enforce_mpp` 控制是否忽略优化器代价估算,强制使用 TiFlash 的 MPP 模式执行查询。
Expand Down

0 comments on commit 65abc6a

Please sign in to comment.