Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline 支持配置 Load 事务大小 #863

Merged
merged 1 commit into from
Mar 29, 2022
Merged

Conversation

wuudjac
Copy link
Contributor

@wuudjac wuudjac commented Nov 4, 2019

功能介绍

为了调节 Load 阶段每次写入目标库的事务大小,支持在 otter manager 配置 otter node 的 com.alibaba.otter.node.etl.load.loader.db.DbLoadAction.batchSize 参数:

manager 界面举例:

添加 pipeline
添加 pipeline

查看 pipeline 信息
查看 pipeline 信息

背景

业务场景为有一张存在突发大量写入(INSERT、DELETE)的表需要通过 otter 进行同步,观察到突发大量写入(3000+ 行/秒)时,同步出现延迟

观察 select 日志和 load 日志,发现:

  • select 消费到批次 -> load 完成写入之间时间间隔较长
  • load 完成写入 -> 下一次 select 消费到批次几乎为瞬时

由于 pipeline 在 E.、T. 阶段没有配置字段转换等规则,推测为 L. 阶段目标库写入存在瓶颈

查看目标库表设计,存在较多索引,同时发现 com.alibaba.otter.node.etl.load.loader.db.DbLoadAction.batchSize 为写死的 50(即 Load 阶段一个事务最多写入 50 条数据),因此怀疑目标库频繁的写入事务重建索引等操作降低了写入的吞吐量,将此数值调大后,发现吞吐量有较大提升

修改前

batchSize = 50,同步出现延迟(代表 Load 打满)时,吞吐量约为 60,000 行/分钟

batchSize-50-吞吐
batchSize-50-吞吐

batchSize-50-延迟
batchSize-50-延迟

修改后

batchSize = 10000,同时调大了消费批次大小以确保每个 batch 行数足够满足每个事务。同步出现延迟时,吞吐量约为 350,000 行/分钟;吞吐量为 88,000 行/分钟 时,没有出现延迟

batchSize-10000-吞吐
batchSize-10000-吞吐

batchSize-10000-延迟
batchSize-10000-延迟

建议配置

如果用户遇到的问题及目标库结构类似,可以进行相似调整,注意以下几点:

  • pipeline 消费批次调大时,需要确保 batch 行数足够,例如 Load 批次大小 10000,消费批次为接近 10000 的整数倍为宜;或者直接将 Load 批次调很大,这样完全以消费的每个 batch 大小作为事务大小,一个 batch 操作正好一个事务
  • 如果 Load 批次大小以及写入并发数配置过大,可能会导致目标库事务执行超时 Load 失败,因此还是需要结合目标库实际的事务执行能力进行评估。在调大 Load 批次大小的同时,可以适当调小写入并发数

@CLAassistant
Copy link

CLAassistant commented Nov 4, 2019

CLA assistant check
All committers have signed the CLA.

@ymakedaq
Copy link

啥时候GA,在哪个版本里面

@linqh1
Copy link

linqh1 commented Aug 13, 2020

有时候一个事务可能会删除数十万的数据,同步直接卡死,延迟时间不断增加
这个改动好像也可以解决这个问题?

@whhe whhe merged commit 6d029dd into alibaba:master Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants