Traffic peak clipping solution

Baidu Encyclopedia Definition:

If you watch the request monitoring curve of the lottery or spike system, you will find that this type of system will have a peak during the time period when the event is open, and when the event is not open, the request volume and machine load of the system are generally relatively stable. . In order to save machine resources, we cannot always provide maximum resource capacity to support short-term peak requests. Therefore, it is necessary to use some technical means to weaken the instantaneous request peak and keep the system throughput controllable under the peak request.

Traffic peak clipping scheme:

Lossless solution: queuing, verification, and hierarchical filtering, without loss of user requests.

Loss solution: current limit, fuse, will lose the request sent by the user.

queue

The message queue is used to buffer the instantaneous traffic, and the synchronous direct call is converted into asynchronous indirect push. In the middle, a queue is used to receive the instantaneous traffic peak at one end, and the message is smoothly pushed out at the other end.

Common messages include RocketMQ, Kafka, RabbitMQ, etc.

verification

Verify the request, increase the complexity of the request, and delay the request. It can also prevent malicious requests and attacks.

For example: graphic verification code, sliding verification code, SMS verification code, etc.

Hierarchical filtration

Use a "funnel" design to process requests, filter out invalid requests as much as possible at different levels, and let the end of the "funnel" be valid requests.

Limiting

Common current limiting algorithms include sliding window, token bucket, leaky bucket, and counter.

The current limiting methods include interface current limiting, user current limiting, IP current limiting, and overall service request current limiting.

You can dynamically limit the current, create a container monitor, and then monitor the operation of the container's CPU, memory and other indicators, and enable the current limit when the threshold is reached. It is also possible to release core requests and restrict non-core requests.

Fuse

Thread pool isolation: After a reasonable estimate of the QPS of an interface during the peak period according to the online production situation, a reasonable number of threads is given to the interface according to the estimated value. If there is a failure, then the server where the interface is located The maximum number of threads allocated will be limited to this number, so that system resources will not be exhausted. At the same time, when the interface is called during peak periods, hystrix can return the request by setting a downgrade strategy.

 

Guess you like

Origin blog.csdn.net/Anenan/article/details/114978342