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

大兴企业网站建设公司官方商城网站建设

大兴企业网站建设公司,官方商城网站建设,外贸网站建设的好处,用织梦做的网站一般后台Sentinel介绍 Sentinel 是面向分布式、多语言异构化服务架构的流量治理组件#xff0c;主要以流量为切入点#xff0c;从流量路由、流量控制、流量整形、熔断降级、系统自适应过载保护、热点流量防护等多个维度来帮助开发者保障微服务的稳定性。 官网 home | Sentinel 下载…Sentinel介绍 Sentinel 是面向分布式、多语言异构化服务架构的流量治理组件主要以流量为切入点从流量路由、流量控制、流量整形、熔断降级、系统自适应过载保护、热点流量防护等多个维度来帮助开发者保障微服务的稳定性。 官网 home | Sentinel 下载 Releases · alibaba/Sentinel · GitHub 中文介绍 介绍 · alibaba/Sentinel Wiki · GitHub Sentinel · alibaba/spring-cloud-alibaba Wiki · GitHub Sentinel启动 java -jar sentinel-dashboard-1.8.7.jar http://localhost:8080 默认账号密码sentinel maven依赖 dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-sentinel/artifactId /dependency 配置文件appliction.yml server:port: 8401spring:application:name: cloud-alibaba-sentinel-servicecloud:nacos:discovery:server-addr: localhost:8848sentinel:transport:dashboard: localhost:8080 #配置sentinel dashboard控制台服务地址port: 8719 # 默认端口8719如果被占用会从8719开始依次1扫描直至找到未被占用端口 其他配置项可参考Sentinel · alibaba/spring-cloud-alibaba Wiki · GitHub 启动类和Controller import com.sunxiao.cloud.service.FlowLimitService; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController;import java.util.concurrent.TimeUnit;Slf4j RestController public class FlowLimitController {Resourceprivate FlowLimitService flowLimitService;GetMapping(/testA)public String testA() {return into ... A ...;}GetMapping(/testB)public String testB() {return into ... B ...;}GetMapping(/testC)public String testC() {flowLimitService.common();return into ... C ...;}GetMapping(/testD)public String testD() {flowLimitService.common();return into ... D ...;}GetMapping(/testE)public String testE() {log.info(E: {}, System.currentTimeMillis());return into ... E ...;}GetMapping(/testF)public String testF() {try {TimeUnit.SECONDS.sleep(1);} catch (InterruptedException e) {throw new RuntimeException(e);}log.info(熔断测试, 慢调用比例);return into ... F ...;}GetMapping(/testG)public String testG() {throw new RuntimeException(模拟异常);} }import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;/*** author sunx* date 2024/4/2*/ SpringBootApplication EnableDiscoveryClient public class Main8401 {public static void main(String[] args) {SpringApplication.run(Main8401.class, args);} } 启动后访问接口查看效果 因为sentinel默认是懒加载的需要调用接口后才能看到. Sentinel流控模式 直接 关联 链路 Sentinel流控效果 预热 排队等待 并发线程数 Sentinel熔断规则 慢调用比例 异常比例 异常数 SentinelResource注解 import com.alibaba.csp.sentinel.annotation.SentinelResource; import com.alibaba.csp.sentinel.slots.block.BlockException; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;Slf4j RestController public class RateLimitController {GetMapping(/rateLimitByUrl)public String rateLimitByUrl() {return 限流测试未使用注解;}GetMapping(/rateLimitByResource)SentinelResource(value ByResource, blockHandler byResourceHandler)public String rateLimitByResource() {return 限流测试使用注解, 返回指定的字符串;}public String byResourceHandler(BlockException blockException) {return 服务不可用, 这是自定义返回的字符串;}GetMapping(/rateLimitByFallback/{i})SentinelResource(value rateLimitByFallback, blockHandler byBlockHandler, fallback byFallback)public String rateLimitByFallback(PathVariable(i) Integer i) {if (i 0) {throw new RuntimeException(i 0 异常);}return 使用注解并使用, Fallback;}public String byBlockHandler(PathVariable(i) Integer i, BlockException blockException) {log.error(配置了自定义限流, {}, blockException.getMessage());return 服务不可用, 这是自定义返回的字符串;}public String byFallback(PathVariable(i) Integer i, Throwable throwable) {log.error(程序逻辑异常, {}, throwable.getMessage());return 逻辑异常, 这是自定义返回的字符串;}GetMapping(/testHotKey)SentinelResource(value testHotKey, blockHandler testHotKeyBlockHandler)public String testHotKey(RequestParam(value p1, required false) String p1,RequestParam(value p2, required false) String p2) {return testHotKey ...;}public String testHotKeyBlockHandler(RequestParam(value p1, required false) String p1,RequestParam(value p2, required false) String p2, BlockException blockException) {return testHotKey blockException ...;}}标注在方法上可以对方法进行限流 默认不用的情况下rest接口默认的熔断返回结果 标注方法上自定义限流返回 标注方法上自定义限流返回服务降级处理。该情况下达到规则条件返回blockHandler方法方法内异常返回fallback。 Sentinel热点规则 针对某个参数传递该参数时进行限流 支持例外项配置如参数p11时不限流p1等于其他值时限流 Sentinel授权规则 可以对请求方的来源进行判断和控制。具体来说,可以通过白名单和黑名单两种方式对调用方的来源进行控制。 自定义处理获取参数serverName值 import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser; import jakarta.servlet.http.HttpServletRequest; import org.springframework.stereotype.Component;Component public class CustomRequestOriginParser implements RequestOriginParser {Overridepublic String parseOrigin(HttpServletRequest httpServletRequest) {return httpServletRequest.getParameter(serverName);} }上述配置表示http://localhost:8401/testA?serverNamex​​​​​​    x12以外的访问会被拒绝。 Sentinel规则持久化到nacos maven依赖 dependencygroupIdcom.alibaba.csp/groupIdartifactIdsentinel-datasource-nacos/artifactId /dependency application.yml: spring:cloud:sentinel:datasource: #sentinel持久化配置ds1: #自定义的keynacos:server-addr: localhost:8848 #nacos地址data-id: ${spring.application.name} #nacos配置中的dataidgroup-id: DEFAULT_GROUP #nacos配置中的groupiddata-type: json #nacos配置中的datatyperule-type: flow # com.alibaba.cloud.sentinel.datasource.RuleType中的 (flow代表流控) 在nacos中设置对应规则后可以在sentinel控制台中看到 Sentinel规则持久化有多种方式更多关于Sentinel规则持久化可以参考【sentinel】Sentinel规则的持久化_sentinel持久化-CSDN博客
http://www.pierceye.com/news/672478/

相关文章:

  • 网站主体注销泰安新闻视频在线
  • 怀柔网站建设优化seo瓯北网站制作公司
  • 福田住房和建设局网站官网做自己点击网站
  • 临沂市建设局网站简介佛山建网站
  • 哪种类型的网站比较难做阿里云宝塔安装wordpress
  • 购物网站起名网站建设皿金手指排名
  • 河北省住房和城市建设厅网站怎么做cpa网站
  • 网站备案 取名资讯通不过软文投放平台有哪些?
  • 民治做网站多少钱好看的企业网站首页
  • 腾讯域名怎么建设网站客户管理系统免费
  • 承德网站建设报价网站建设中企动力最佳a5
  • 图书馆第一代网站建设海口会计报名网站
  • 网站设计师简介中国工厂网站官方网站
  • 广州移动 网站建设十大职业资格培训机构
  • 网站建设维护协议书网站开发程序用什么好
  • 零基础做网站教程天猫商城商品来源
  • 广州知名网站建设公司教育机构培训
  • 做游戏解说上传在什么网站好企业网站定制
  • 用iis浏览网站南宁网站seo大概多少钱
  • 如何用手机网站做淘宝客wordpress 免费 旅游
  • 青岛网站建设网站制作seo顾问服务福建
  • phpcms网站织梦 网站栏目管理 很慢
  • 金融网站 改版方案seo推广优化培训
  • 博物馆设计网站推荐网站布局有哪些常见的
  • 外贸网站建设980ps软件需要付费吗
  • 网站开发后的经验总结北新泾街道网站建设
  • 深圳市南山区住房和建设局网站国内知名网站建设伺
  • 企业网站建设制作的域名费用做的网站怎么上传
  • c++可视化界面设计搜索引擎优化自然排名的区别
  • 网站开发工作网络营销的网站分类有