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 ...
随机推荐
- Python文件操作大全,随机删除文件夹内的任意文件
在读文件的时候往往需要遍历文件夹,python的os.path包含了很多文件.文件夹操作的方法: os.path.abspath(path) #返回绝对路径os.path.basename(path ...
- tc:逼良为娼
tc的学习原来是想着直接从用户态学习的,但是万万没想到哇,qdisc class两个概念直接把我给搞晕了,直接看代码吧 调用:tc qdisc add dev tap0 root handle 1: ...
- 内存交换空间(swap)的构建
一.使用物理分区构建swap 1.先进行分区的行为. [root@iZ255cppmtxZ ~]# fdisk /dev/xvdb Welcome to fdisk (util-linux ). Ch ...
- arp获取
getarp.c /* getarp.c -- This simple program uses an IOCTL socket call to read an entry */ /* from th ...
- 手机端浏览器适配,background 背景平铺 ,有的出不来
.mobilePage .report { background: url(../images/mobile-report.png) repeat; background-size: 100% :/* ...
- arc076 F - Exhausted? (霍尔定理学习)
题目链接 Problem Statement There are M chairs arranged in a line. The coordinate of the i-th chair ($$$1 ...
- CF#312 558e A Simple Task
~~~题面~~~ 题解: 观察到字母只有26个,因此考虑对这26个字母分别维护,每个线段树维护一个字母,如果一个线段树的某个叶节点有值,表示当前叶节点所在位置的字母是现在这个线段树代表的字母. 那么对 ...
- POJ3498:March of the Penguins——题解
最近的题解的故事背景割. 题目: 描述 在靠近南极的某处,一些企鹅站在许多漂浮的冰块上.由于企鹅是群居动物,所以它们想要聚集到一起,在同一个冰块上.企鹅们不想把自己的身体弄湿,所以它们在冰块之间跳跃, ...
- BZOJ1047:[HAOI2007]理想的正方形——题解
http://www.lydsy.com/JudgeOnline/problem.php?id=1047 https://www.luogu.org/problemnew/show/P2216#sub ...
- BZOJ1068:[SCOI2007]压缩——题解
http://www.lydsy.com/JudgeOnline/problem.php?id=1068 Description 给一个由小写字母组成的字符串,我们可以用一种简单的方法来压缩其中的重复 ...