Joke Collection Website - Public benefit messages - SpringCloud uses Zuul (spring-cloud-zuul-ratelimit).
SpringCloud uses Zuul (spring-cloud-zuul-ratelimit).
Description:
Github address of Spring Cloud Zuul Rate Limit project:
/marcosbarbero/ Spring-cloud-zuul-ratelimit
This package realizes that in Zuul's development of micro-services, it is sometimes necessary to limit the flow of the API to prevent network attacks, such as making a short message verification code API. Limiting the request rate of the client can resist the short message bombing attack to a certain extent and reduce losses. Micro-service gateway is the necessary entrance for every request, which is very suitable for API flow limiting and authentication. This paper introduces how Zuul performs flow limiting.
Personal suggestion: If the micro-service business changes at the gateway, the gateway will also change, and it involves calls between micro-services. This gateway can't limit the flow. Therefore, fine-grained current limiting cannot be done on the gateway. The gateway mainly limits the concurrent processing ability of the server hardware equipment, and the fine-grained current limiting is still handed over to a special fuse current limiting micro-service. This is conducive to the deconstruction of micro-services and the collaborative development of teams
1. Current limiting strategy
2. Available realization
Bucket4j requires related bean @ qualifier ("rate limit"):
3. Common configuration attributes
Related attributes of policy
4. How to deal with an error
1. Import a dependency
2. Start a class annotation solution
3. Configure a file
4. Visit after starting
Because we are configured to allow only three requests per second, when we exceed it, Too many request exceptions will be thrown
5. Customize the Key policy
If you want to control the key policy yourself, you can add your own policy logic by customizing the implementation of the RateLimitKeyGenerator.
instance:
the request is restricted according to the parameters on the request. For example, a request is http://localhost: 97/API-a//hello 2? Name=kevin, and current is limited for the same name value. We set the current limit to be 1 times within 1 minute, so if the request for the name of kevin exceeds 1 times within 1 minute, the current limit will occur.
implementation of custom RateLimitKeyGenerator:
this article ends!
reference:
- Related articles
- Sending ambiguous messages to married women without replying or rejecting them
- The omen of dreaming of a long factory building
- Learn how to cancel automatic renewal
- Write to my sister and wish her a happy marriage.
- The theme of the fruit class is how to send the message that children bring fruit.
- Is it true that Industrial Bank only allows repayment without sending text messages?
- The feeling of communicating with parents should be no less than 600 words.
- Cangzhou Bank lion city Kaka fee charging standard
- Kiku spilled water on Xuanyi's skirt. What's their reaction?
- Old classmates' birthday greetings are short and unique.