Netty study notes abstract quote

Netty prevents memory leaks:

https://blog.csdn.net/gt9000/article/details/88206340

It also mentioned one point:
Malformed bitstream attack: If the client deliberately forges the message length value very large according to the protocol specification, it may cause the receiver's memory to overflow.
Code BUG: Incorrectly setting or encoding the message length field to a very large value may cause the other party's memory to overflow.

These also require me to consider interception.

The strategies to avoid memory leaks are as follows:

No matter which decoder is used for implementation, the maximum length of the message is limited. When the limit is exceeded, a decoding failure exception will be thrown. The user can choose to ignore the currently read message or close the link directly.
Take Netty's DelimiterBasedFrameDecoder code as an example. When creating a DelimiterBasedFrameDecoder object instance, specify a reasonable maximum message length limit to prevent memory overflow:

Send backlog causes OOM memory leak:

https://blog.csdn.net/MarchRS/article/details/103952718

Other factors that may cause the backlog of the sending queue
However, in actual situations, it is not only high-concurrency scenarios that will cause the message backlog. In some abnormal scenarios, although the traffic is not large, it may still cause the message backlog. The scenarios are as follows:

Network bottleneck. When the sending speed exceeds the processing capacity of the network link, it will cause the sending queue backlog.
When the reading speed of the peer is lower than the sending speed of the own party , causing its own TCP sending buffer to be full and frequent write 0 bytes, the message to be sent will be in Netty Queued in the sending queue. When there is a large number of queues, it is easy to cause a direct memory leak in Netty.
————————————————
Copyright Statement: This article is the original article of the CSDN blogger "MarchRS", which follows the CC 4.0
BY-SA copyright agreement. Please attach the original source link and this statement for reprinting .
Original link: https://blog.csdn.net/MarchRS/article/details/103952718

Netty's buffer traffic shaping explanation:

https://www.jianshu.com/p/6c4a7cbbe2b5

Netty-message sending working mechanism:

https://blog.csdn.net/MarchRS/article/details/103919942

Guess you like

Origin blog.csdn.net/Stephanie_1/article/details/107711776