当前位置:网站首页>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 22:23: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
Click on 「 Read the original 」, receive Pulsar vs Kafka The latest evaluation report PDF!
This article is from WeChat official account. - StreamNative(StreamNative).
If there is any infringement , Please contact the [email protected] Delete .
Participation of this paper “OSC Source creation plan ”, You are welcome to join us , share .
边栏推荐
- 将Nagios监控信息存入MySQL
- B_ QuRT_ User_ Guide(35)
- Swift5.0 ----Swift FrameWork的创建及使用
- 电脑版微信文件存储在哪个文件夹可以找到
- 深入解析 Apache BookKeeper 系列:第四篇—背压
- Is Wu Enda's machine learning suitable for entry?
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
- Where can I find the computer version of wechat files
- 谈谈数字化转型的几个关键问题
- 总结的一些内存问题
猜你喜欢

电脑设备管理器在哪里可以找到

Uniapp routing uni simple router

基于kubernetes平台微服务的部署

【BSP视频教程】BSP视频教程第19期:单片机BootLoader的AES加密实战,含上位机和下位机代码全开源(2022-06-26)

On several key issues of digital transformation

机器学习工作要求研究生吗?

PostgreSQL存储结构浅析
![[micro service ~nacos] configuration center of Nacos](/img/c3/9d8fb0fd49a0ebab43ed604f9bd1cc.png)
[micro service ~nacos] configuration center of Nacos

How does win11 optimize services? Win11 method of optimizing service

Anfulai embedded weekly report no. 270: June 13, 2022 to June 19, 2022
随机推荐
How does win11 optimize services? Win11 method of optimizing service
Error filesystemexception: /data/nodes/0/indices/gttxk-hntgkhacm-8n60jw/1/index/ es_ temp_ File: structure needs cleaning
latex左侧大括号 latex中大括号多行公式
Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
What is the experience of pairing with AI? Pilot vs alphacode, Codex, gpt-3
Golang application ━ installation, configuration and use of Hugo blog system
Stinky tofu made by Grandma
【Android,Kotlin,TFLite】移动设备集成深度学习轻模型TFlite(物体检测篇)
Do machine learning jobs require graduate students?
KVM IO performance test data
基于kubernetes平台微服务的部署
[introduction to MySQL] the first conversation · first time in the "database" Mainland
Architecture of IM integrated messaging system sharing 100000 TPS
Label Contrastive Coding based Graph Neural Network for Graph Classification
Web APIs comprehensive case -tab column switching - dark horse programmer
Zhoushaojian, rare
Femas: cloud native multi runtime microservice framework
A new one from Ali 25K came to the Department, which showed me what the ceiling is
[untitled] first time to participate in CSDN activities
Is machine learning suitable for girls?