zuul进行rate limit
maven
<dependency>
<groupId>com.marcosbarbero.cloud</groupId>
<artifactId>spring-cloud-zuul-ratelimit</artifactId>
<version>1.0..RELEASE</version>
</dependency>
配置
product:
ribbon:
listOfServers: 192.168.99.100:
zuul:
routes:
product:
path: /product/**
stripPrefix: false
ratelimit:
enabled: true #default false
behind-proxy: true #default false
policies:
product:
limit: 10
refresh-interval: 120 #60 default value (in seconds)
type: #optional
- user
- origin
- url
spring:
redis:
timeout: 10
database: 0
host: 192.168.99.100
port: 6379
pool:
max-active: 8
max-idle: 8
max-wait: -1
min-idle: 0
filterOrder
类似spring-core-4.3.4.RELEASE-sources.jar!/org/springframework/core/Ordered.java
/**
* Useful constant for the highest precedence value.
* @see java.lang.Integer#MIN_VALUE
*/
int HIGHEST_PRECEDENCE = Integer.MIN_VALUE;
/**
* Useful constant for the lowest precedence value.
* @see java.lang.Integer#MAX_VALUE
*/
int LOWEST_PRECEDENCE = Integer.MAX_VALUE;
默认越小优先级越高,排查负数的情况下,0优先级最高
RateLimitFiltercom/marcosbarbero/zuul/filters/pre/ratelimit/RateLimitFilter.java
它的order为-1,表示更先执行
测试
wrk -t12 -c100 -d10s -T30s --latency http://localhost:8080/product
限流结果:
workspace curl -i http://localhost:8080/product\?debug=true
HTTP/1.1 429
X-Application-Context: application
X-RateLimit-Limit: 10
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 13000
Content-Length: 0
Date: Sun, 09 Apr 2017 06:44:02 GMT
doc
zuul进行rate limit的更多相关文章
- 服务接口API限流 Rate Limit
一.场景描述 很多做服务接口的人或多或少的遇到这样的场景,由于业务应用系统的负载能力有限,为了防止非预期的请求对系统压力过大而拖垮业务应用系统. 也就是面对大流量时,如何进行流量控制? 服务接口的流量 ...
- nginx rate limit
nginx rate limithttps://www.topjishu.com/12139.htmlhttps://blog.csdn.net/hellow__world/article/detai ...
- 关于Homebrew出现GitHub API rate limit错误的解决方法
参考博文: http://havee.me/mac/2013-12/how-to-install-and-use-homebrew.html Error: GitHub API rate limit ...
- java 服务接口API限流 Rate Limit
一.场景描述 很多做服务接口的人或多或少的遇到这样的场景,由于业务应用系统的负载能力有限,为了防止非预期的请求对系统压力过大而拖垮业务应用系统. 也就是面对大流量时,如何进行流量控制? 服务接口的流量 ...
- 服务接口API限流 Rate Limit 续
一.前言 上一篇文章中粗浅的介绍使用Redis和基于令牌桶算法进行对服务接口API限流,本文介绍另一种算法---漏桶算法的应用.Nginx想必大家都有所了解是一个高性能的 HTTP 和反向代理服务器, ...
- springcloud实践(二)之api网关:zuul
zuul是什么? front door. API Gateway.Zuul is a JVM based router and server side load balancer by Netflix ...
- springboot+zuul(一)------实现自定义过滤器、动态路由、动态负载。
参考:https://blog.csdn.net/u014091123/article/details/75433656 https://blog.csdn.net/u013815546/articl ...
- 高可用服务设计之二:Rate limiting 限流与降级
<高可用服务设计之二:Rate limiting 限流与降级> <nginx限制请求之一:(ngx_http_limit_conn_module)模块> <nginx限制 ...
- How To Change Log Rate Limiting In Linux
By default in Linux there are a few different mechanisms in place that may rate limit logging. These ...
随机推荐
- java 基础 --匿名内部类-008
不全代码 interface Inter(){void show();} class Outer{补全代码} class OuterDemo{ public static void main(Stri ...
- Atom IDE开发工具, ASCII艺术评论, ninimap 插件
1 ASCII Art Comments One neat trick is to use ASCII art to create huge comments visible in the minim ...
- Activiti5工作流笔记二
流程变量 import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import org.activiti ...
- 【bzoj2100】[Usaco2010 Dec]Apple Delivery 最短路
题目描述 Bessie has two crisp red apples to deliver to two of her friends in the herd. Of course, she tr ...
- [BZOJ4036] [HAOI2015]按位或
传送门:https://lydsy.com/JudgeOnline/problem.php?id=4036 Description 刚开始你有一个数字0,每一秒钟你会随机选择一个[0,2^n-1]的数 ...
- 【以前的空间】vijos 1720 阿狸的打字机
https://www.vijos.org/p/1720 作为一个一个蒟蒻,跪了三个星期,终于在蔡大神的帮助下a了.这题网上的题解很多,不过大都把题解写的太简单了(对因为大神的题解只有三个字:傻叉题) ...
- 51nod 1486 大大走格子(DP+组合数学)
枚举不合法点的思想. 把障碍x坐标为第一关键字,y坐标为第二关键字排序.f[i]表示走到第i个障碍的方案数. f[i]=C(x[i]+y[i]-2,x[i]-1)-sigma(f[j]*C(x[i]- ...
- [学习笔记]Segment Tree Beats!九老师线段树
对于这样一类问题: 区间取min,区间求和. N<=100000 要求O(nlogn)级别的算法 直观体会一下,区间取min,还要维护区间和 增加的长度很不好求.... 然鹅, 从前有一个来自杭 ...
- 【贪心】【CF3D】 Least Cost Bracket Sequence
传送门 Description 给一个序列,序列里面会有左括号.问号.右括号.对于一个\(?\)而言,可以将其替换为一个\((\),也可以替换成一个\()\),但是都有相应的代价.问:如何替换使得代价 ...
- 【HASH】【UVA 10125】 Sumset
传送门 Description 给定一个整数集合S,求一个最大的d,满足a+b+c=d,其中a,b,c,d∈S Input 多组数据,每组数据包括: 第一行一个整数n,代表元素个数 下面n行每行一个整 ...