springcloud:3.6测试信号量隔离

服务提供者【test-provider8001】

Openfeign远程调用服务提供者搭建

文章地址http://t.csdnimg.cn/06iz8

相关接口

测试远程调用:http://localhost:8001/payment/index

服务消费者【test-consumer-resilience4j8004】

Openfeign远程调用消费者搭建

文章地址http://t.csdnimg.cn/06iz8

依赖

java 复制代码
 <!-- resilience4j隔离依赖  -->
        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-bulkhead</artifactId>
            <version>1.7.0</version>
        </dependency>
        <!-- resilience4j  -->
        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-spring-cloud2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
        </dependency>

application.yml

java 复制代码
resilience4j:
  #信号量隔离
  bulkhead:
    instances:
      # 实例名称:自己定义的名称,对应@Bulkhead的name
      backendA:
        # 隔离允许并发线程执行的最大数量
        maxConcurrentCalls: 5
        # 当达到并发调用数量时,新的线程的阻塞时间
        maxWaitDuration: 20ms

OrderController【控制层】

java 复制代码
 /**
     * 测试信号量隔离
     *
     * @return
     */
    @GetMapping("/bulkhead")
    @Bulkhead(name = "backendA", type = Bulkhead.Type.SEMAPHORE)
    //name:对应的配置名,type:隔离类型-信号量/线程
    public String bulkhead() throws InterruptedException {
        log.info("************** 进入方法 *******");
        TimeUnit.SECONDS.sleep(10);
        String index = paymentFeignService.paymentIndex();
        log.info("************** 离开方法 *******");
        return index;
    }

相关接口

测试信号量隔离:http://localhost:8004/order/bulkhead

jmeter测试思路

此配置隔离并发线程最大数量为5,所以jmeter我们采用大于5个线程进行测试

相关推荐
你的人类朋友3 小时前
说说签名与验签
后端
databook3 小时前
Manim实现脉冲闪烁特效
后端·python·动效
canonical_entropy7 小时前
AI时代,我们还需要低代码吗?—— 一场关于模型、演化与软件未来的深度问答
后端·低代码·aigc
颜如玉7 小时前
HikariCP:Dead code elimination优化
后端·性能优化·源码
考虑考虑8 小时前
Jpa使用union all
java·spring boot·后端
bobz9659 小时前
virtio vs vfio
后端
Rexi9 小时前
“Controller→Service→DAO”三层架构
后端
bobz96510 小时前
计算虚拟化的设计
后端
深圳蔓延科技10 小时前
Kafka的高性能之路
后端·kafka
Barcke10 小时前
深入浅出 Spring WebFlux:从核心原理到深度实战
后端