改造限流策略的针对来源选项
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class SentinelConfig {@Beanpublic RequestOriginParser requestOriginParser() {return (request -> {//ip地址String remoteAddr = request.getRemoteAddr();return remoteAddr;});}
}
设置规则(只能填入一个限制IP,多个IP需要设置多条规则)
IP流控规则
总结:IP为127.0.0.1的请求限制为1QPS,总请求限制为3QPS,单个IP请求限制不能大于default请求限制,default默认生效。