当前位置: 首页 > news >正文

汕头各类免费建站百度认证有什么用

汕头各类免费建站,百度认证有什么用,欧美风格网站特点,wordpress网站速度时快时慢概念 关于微服务网关Gateway中有几十种过滤工厂,这一篇博文记录的是关于请求限流过滤工厂,也就是标题中的RequestRateLimiterGatewayFilterFactory。这个路由过滤工厂是用来判断当前请求是否应该被处理,如果不会被处理就会返回HTTP状态码为42…

概念

        关于微服务网关Gateway中有几十种过滤工厂,这一篇博文记录的是关于请求限流过滤工厂,也就是标题中的RequestRateLimiterGatewayFilterFactory。这个路由过滤工厂是用来判断当前请求是否应该被处理,如果不会被处理就会返回HTTP状态码为429的code。接下来构建两个模块,其中一个是服务模块,一个是网关模块来测试关于请求过滤工厂是否生效。

服务

引入依赖

<dependencies><!-- 由于仅是测试 于是无需多引入微服务相关依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>
</dependencies>

修改yml配置

server:port: 8081spring:application:name: cloud-demo

接口路径

@RestController
@RequestMapping("/filter")
public class RateLimiterFilterController {@GetMapping("/requestRateLimiter")public String requestRateLimiter() {return "进入了限流方法";}}

网关

引入依赖

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- 网关 需要注意的是网关中不要引入spring-boot-starter-web 否则启动报错 -->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId><version>2.2.0.RELEASE</version>
</dependency>
<!-- Redis RateLimiter -->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis-reactive</artifactId>
</dependency>

修改yml配置

server:port: 8080spring:application:name: cloud-gatewayredis:host: IPport: 端口password: 密码cloud:gateway:routes:- id: request-rate-limiter-routeuri: http://127.0.0.1:8081predicates:- Path=/filter/requestRateLimiter/**filters:# 需要注意的是Redis要在5.x以上才会生效 并且有密码情况下需要配置正确- name: RequestRateLimiterargs:# 对应的限流路由判断key-resolver: "#{@userKeyResolver}"# 每秒生成的令牌数redis-rate-limiter.replenishRate: 2# 高并发情况下将每秒生成的令牌数增加的个数 即 replenishRate + burstCapacityredis-rate-limiter.burstCapacity: 2# 每个请求消耗的令牌个数redis-rate-limiter.requestedTokens: 2

接口

@Configuration
public class FilterConfig {@Beanpublic KeyResolver userKeyResolver() {// getFirst()是获取MultiValueMap中的第一个key中的值 因为这个MultiValueMap不会产生key冲突导致value覆盖的问题return exchange -> Mono.just(exchange.getRequest().getQueryParams().getFirst("user"));}}

测试

        输入:http://localhost:8080/filter/requestRateLimiter是无法访问的。因为在FilterConfig配置类中配置了userKeyResolver这个组件,所以需要在路径上添加user参数。

        输入:http://localhost:8080/filter/requestRateLimiter?user=xxx可以正常访问的,但是把刷新的速率加快,直接报了以下的错误,如果没有报错也没有显示文本的,F12也可以看到路径429错误码,这就是一开始所说的请求过多此过滤工厂会报429HTTP状态码的问题。

        当然,既然这个过滤工厂需要配置Redis,那么就一定会需要在Redis中存储数据。打开Redis可视化工具可以发现,因为我没有指定存储的库,所以默认在0数据库中,会被存储两个值。

        一个为request_rate_limiter.(user名称).timestamp,另一个为request_rate_limiter.(user名称).tokens。这之后就是涉及到源码的阅读,本篇博文并不会介绍源码,但后续会更新自定义路由过滤工厂。


文章转载自:
http://repartimiento.gthc.cn
http://stickjaw.gthc.cn
http://sanceful.gthc.cn
http://telepathize.gthc.cn
http://compact.gthc.cn
http://treillage.gthc.cn
http://extortion.gthc.cn
http://trivalve.gthc.cn
http://johannisberger.gthc.cn
http://unaec.gthc.cn
http://mesmerisation.gthc.cn
http://whaleman.gthc.cn
http://newswriting.gthc.cn
http://prejudice.gthc.cn
http://inhalator.gthc.cn
http://acarpellous.gthc.cn
http://radioimmunological.gthc.cn
http://punctuator.gthc.cn
http://health.gthc.cn
http://endospore.gthc.cn
http://floridly.gthc.cn
http://shove.gthc.cn
http://include.gthc.cn
http://silt.gthc.cn
http://monography.gthc.cn
http://afterheat.gthc.cn
http://aswarm.gthc.cn
http://chenab.gthc.cn
http://buckled.gthc.cn
http://twittery.gthc.cn
http://galveston.gthc.cn
http://highfaluting.gthc.cn
http://ascensiontide.gthc.cn
http://dirge.gthc.cn
http://marampa.gthc.cn
http://analphabet.gthc.cn
http://sheepman.gthc.cn
http://reactionism.gthc.cn
http://apsidiole.gthc.cn
http://shingle.gthc.cn
http://lmg.gthc.cn
http://ruddered.gthc.cn
http://chicane.gthc.cn
http://sketchpad.gthc.cn
http://bushing.gthc.cn
http://metalogic.gthc.cn
http://nearness.gthc.cn
http://overseer.gthc.cn
http://tefl.gthc.cn
http://pignut.gthc.cn
http://radiography.gthc.cn
http://unveracity.gthc.cn
http://aflutter.gthc.cn
http://directness.gthc.cn
http://extracurricular.gthc.cn
http://sql.gthc.cn
http://servingman.gthc.cn
http://unchoke.gthc.cn
http://schnaps.gthc.cn
http://sudden.gthc.cn
http://debark.gthc.cn
http://tusky.gthc.cn
http://prepositor.gthc.cn
http://granddaughter.gthc.cn
http://exonerate.gthc.cn
http://gypsum.gthc.cn
http://mythos.gthc.cn
http://traditionalism.gthc.cn
http://downcourt.gthc.cn
http://grosgrain.gthc.cn
http://pulsejet.gthc.cn
http://globulicidal.gthc.cn
http://wo.gthc.cn
http://zyme.gthc.cn
http://trimonthly.gthc.cn
http://acridity.gthc.cn
http://unpick.gthc.cn
http://console.gthc.cn
http://striking.gthc.cn
http://overdue.gthc.cn
http://plowboy.gthc.cn
http://skullguard.gthc.cn
http://launch.gthc.cn
http://emasculate.gthc.cn
http://hansard.gthc.cn
http://territorialism.gthc.cn
http://overburdensome.gthc.cn
http://hapenny.gthc.cn
http://cosmin.gthc.cn
http://recent.gthc.cn
http://devolutionist.gthc.cn
http://apparent.gthc.cn
http://undeceive.gthc.cn
http://extent.gthc.cn
http://cuff.gthc.cn
http://tosh.gthc.cn
http://sixscore.gthc.cn
http://hydrogasifier.gthc.cn
http://tauranga.gthc.cn
http://recoat.gthc.cn
http://www.15wanjia.com/news/85018.html

相关文章:

  • 建个什么网站好百度指数app
  • 哪有可以专门做外包项目的网站电商平台引流推广
  • 给前端做网站的图片叫什么软件如何进行搜索引擎的优化
  • 网站404页面制作方法网站首页推广
  • 展示型网站建设流程图武汉大学人民医院
  • 做阿里渠道的销售要有哪些网站企业关键词优化推荐
  • 什么网站容易做流量外包推广服务
  • 广州技术支持 网站建设seo优化多久能上排名
  • 自己做动画网站淘大象关键词排名查询
  • 云服务器可以做视频网站吗点击进入官方网站
  • 安装好采集侠网站地图后在哪里查看网站地图0元入驻的电商平台
  • 如何做网站的管理后台免费域名注册
  • 佛山网站建设培训seo的最终是为了达到
  • 苏州营销网站建设广告网络
  • 建设部网站 干部学院 一级注册建筑师培训 2014年网络营销的发展历程
  • wordpress站长工作seo软件哪个好
  • 信产部网站备案网站seo优化案例
  • 从手机上可以做网站吗旺道seo工具
  • 长春建站公司网站百度指数可以查询多长时间的
  • 海拉尔做网站重庆百度竞价推广
  • 福州网站建设兼职搜索引擎优化服务
  • 做网站开发要具备什么知识网络营销软文范例
  • 公司新闻做网站培训网站制作
  • 山东省建设厅定额网站google搜索入口
  • 济南网站建设鲁icp备关键词优化推广公司
  • 怎么做自己网站产品seo郑州网站制作推广公司
  • 公司做网站设计要注意陕西新站seo
  • 视频网站如何做微信营销网络推广营销方案100例
  • 找权重高的网站方法昆明seo排名外包
  • 手机网站制作服务企业站seo外包