当前位置:网站首页>In depth analysis of Apache bookkeeper series: Part 4 - back pressure
In depth analysis of Apache bookkeeper series: Part 4 - back pressure
2022-06-30 11:42:00 【StreamNative】
This paper is written by StreamNative Organization translation from 《Apache BookKeeper Internals — Part 4 — Back Pressure》, author Jack Vanlightly,Apache BookKeeper Committer.
Translator information
Zhangwenfeng , Love to share , Embrace open source , Community nickname zeroGozhang, Now he is the big data architect of xinghuan information technology finance .
This series of blogs is based on Apache Pulsar Configured Apache BookKeeper 4.14 To write .
In this article , We will introduce BookKeeper All back pressure mechanisms used by the server nodes , To protect yourself from read and write overloads . Back pressure mechanism is necessary in any data system , It can not only prevent resource exhaustion , At the same time, it can make the system handle overload more gracefully and smoothly . When Bookie Overload , Ideally , We hope it will continue to provide high throughput for the content it can handle , And reject other requests .
Some components restrict the data structures in their memory , To prevent Bookie Run out of memory . for example , in the light of Journal The line will be right entry Limit the number of , Write cache has a limit on the number of bytes written . in fact , The write cache is pre allocated , So no matter Bookie What's the load of , Its memory usage is fixed .
By default , Other components are unlimited , For example, suspended Netty Mission . Besides , Even after considering all the different limitations of the internal buffer , When they are combined, they may exceed Bookie Memory limit of .
Let's take a look at various back pressure and memory limitation mechanisms .

chart 1: Location of various back pressure mechanisms
1 - Total number of writes in progress
We can do it through configuration maxAddsInProgressLimit Parameter controls the total number of writes in progress . When the total number of write requests in progress reaches this limit , The system will block those processing new write requests Netty Threads , Until the number of writes in progress falls below this limit again . When Netty Stop reading data from network buffer , Data will be overstocked in TCP Buffer zone , triggering TCP Built in back pressure mechanism , Notify the upstream sender and suspend sending , take TCP Back pressure is applied to the client .
This can effectively avoid the thread pool task queue 、Journal Queue, etc. caused by backlog of too many requests OutOfMemory error . There are no restrictions by default .
2 - Total number of reads in progress
We can also configure maxReadsInProgressLimit Parameters , Limit the total number of reads in progress . This triggers the same Netty Thread blocking behavior .
3 - Number of pending write requests per write thread pool thread
We can also limit the size of the write thread pool task queue ( To configure maxPendingAddRequestsPerThread, The default value is 10000), To reduce the number of pending write requests . Once the task queue is full , The client will receive TOO_MANY_REQUESTS Response , Causes the client to choose another Bookie To write .
4 - The number of pending read requests per read thread pool thread
The size of the read thread pool task queue can be limited in the same way as the write thread pool ( To configure maxPendingReadRequestsPerThread). Once the task queue is full , Read requests begin to be rejected in the same way as write requests , The affected client will choose another Bookie To read .
5 - Journal queue
Journal Get task from blocking queue . When Journal When the queue size reaches its maximum due to the gradual failure to keep up with the filling speed of the queue , The writing thread will be blocked , No more work can be performed until there is space on the queue .
Next , The write thread task queue will be filled , Write requests will begin to be rejected .
6 - DbLedgerStorage Write denied
If the active write cache is full , The swapped write cache is not yet available ( Because it's still brushing the plate ), be Bookie Unable to process more writes . Only when an empty write cache becomes available , It can accept more writes . therefore , When no write cache is available after waiting for a period of time ( By default 10 second , from dbStorage_maxThrottleTimeMs Definition ), Write requests will be rejected .
stay BookKeeper 4.14 In the version , This will result in a generic error code being returned to the client , instead of TOO_MANY_REQUESTS Code . This problem will be fixed in a future release .
7 - Netty Non writable channel
In order to prevent the passage of Netty The channel is out of memory when sending a response to the client , Can pass waitTimeoutOnResponseBackpressureMs Parameter configuration fallback mechanism . If the channel buffer is full , bring Netty The channel becomes non writable , The write response may be delayed to the corresponding waiting time . If the channel is still not writable , The system will not send a response , And it will send an indicator of channel error . If this fallback mechanism is not configured , Although its status is not writable , The response will still be sent to the channel ; If too many bytes are sent along the channel , May cause out of memory errors .
Besides ,Netty The number of queued tasks can also be determined by using Java Attribute to limit :io.netty.eventLoop.maxPendingTasks. This parameter also prevents Netty Thread accepts too many tasks .
summary
The back pressure applied by the receiving end will propagate upward along the link , Until we reach the source . about BookKeeper Come on , Back pressure usually starts from Journal and DbLedgerStorage Component start , Then it goes up the link to the thread pool ( Their task queues )、Netty, Finally arrive at the client .
But for the Apache Pulsar For clusters , More than that .Pulsar Broker It also has its own internal back pressure mechanism , It will eventually trigger a return to Pulsar producers and consumers .
This is the last article in this series . Next , We are going to launch a series of new blogs , The content is about BookKeeper Some indicators produced , And how to use the thinking patterns we tried to build in this series to explain them .
Recommended reading
1. In depth analysis of Apache BookKeeper series : Chapter one — Framework principle
2. In depth analysis of BookKeeper Multi copy agreement ( One )
3. In depth analysis of Apache BookKeeper series : Second articles — Write operation principle
4. Apache BookKeeper Insight ( One ) — External consensus and dynamic members
5. In depth analysis of Apache BookKeeper series : Third articles —— Reading principle
▼ Focus on 「Apache Pulsar」, Get dry and dynamic ▼
reply BookKeeper, Join in Pulsar Storage team

Click on 「 Read the original 」, receive Pulsar vs Kafka The latest evaluation report PDF!
边栏推荐
- 考研这些“不靠谱”的经验有多害人?
- 【重温经典C语言】~c语言中%x、%c、%d、%x等等等、c语言取地址符&的作用、C语言中的 联合体
- 华三交换机清空配置
- 导致系统性能失败的10个原因
- 创建型-配置工厂
- “新数科技”完成数千万元A+轮融资,造一体化智能数据库云管理平台
- 8 lines of code to achieve quick sorting, easy to understand illustrations!
- Filter error in dplyr: can't transform a data frame with duplicate names
- Qt嵌入子Qt程序窗口到当前程序
- koa - 洋葱模型浅析
猜你喜欢

一个悄然崛起的国产软件,低调又强大!

记一次ViewPager + RecyclerView的内存泄漏

Is the golden cycle of domestic databases coming?

据说用了这个,老板连夜把测试开了

阿里云李飞飞:中国云数据库在很多主流技术创新上已经领先国外

启明星辰集团运维安全网关(堡垒机)再次夺得榜首!

暑假学习记录

一瓶水引发的“战争”

Wechat Emoji is written into the judgment, and every Emoji you send may become evidence in court

“新数科技”完成数千万元A+轮融资,造一体化智能数据库云管理平台
随机推荐
数字化不是试出来,而是蹚出来的|行知数字中国 × 富士康史喆
深入解析 Apache BookKeeper 系列:第四篇—背压
Is the golden cycle of domestic databases coming?
EMC surge
Database cascading operation
Handler source code analysis
国内首批!阿里云云原生数据湖产品通过信通院评测认证
QT embeds the sub QT program window into the current program
CVPR 2022 | 大幅减少零样本学习所需人工标注,马普所和北邮提出富含视觉信息的类别语义嵌入...
相对位置编码Transformer的一个理论缺陷与对策
微信表情符号被写入判决书,你发的每个 emoji 都可能成为呈堂证供
启明星辰集团运维安全网关(堡垒机)再次夺得榜首!
Flutter 从零开始 008 表单
HMS Core音频编辑服务3D音频技术,助力打造沉浸式听觉盛宴
100 important knowledge points that SQL must master: using stored procedures
据说用了这个,老板连夜把测试开了
Webview,ScrollView滑动冲突咋整
[applet practice series] Introduction to the registration life cycle of the applet framework page
The jetpack compose dropdownmenu is displayed following the finger click position
Line generation (Gauss elimination method, linear basis)