Rate Limiting
The rate limiting rule is based on Resilience4j and works on the server. The principles are as follows: A maximum of rate requests can be accepted at the interval specified by limitRefreshPeriod. If the number of requests exceeds the value of rate, the traffic is limited and the response code 429 is returned.
- Rate limiting of Java chassis is used for microservice providers. The rate limiting module must be integrated into microservice applications and the qps-flowcontrol-provider processing chain must be enabled.
Configuration example:
servicecomb: handler: chain: Provider: default: qps-flowcontrol-provider
Add the following dependency to the POM file:
<dependency> <groupId>org.apache.servicecomb</groupId> <artifactId>handler-flowcontrol-qps</artifactId> <version>${project.version}</version> </dependency>
For details, see ServiceComb Rate Limiting Development Guide.
- Spring Cloud uses Aspect to intercept RequestMappingHandlerAdater to implement rate limiting. After Spring Cloud Huawei is integrated, the rate limiting module spring-cloud-starter-huawei-governance is integrated by default. You only need to enable a specific rate limiting policy.
servicecomb: matchGroup: AllOperation: | matches: - apiPath: prefix: "/" rateLimiting: AllOperation: | rate: 10 # A maximum of 10 requests are allowed in a period of time.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot