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个线程进行测试

相关推荐
前端一小卒7 小时前
我用 Claude Code 的 Superpowers 技能链写了个服务,部署前差点把服务器搞炸
前端·javascript·后端
曹牧9 小时前
Spring:@RequestMapping注解,匹配的顺序与上下文无关
java·后端·spring
阿丰资源10 小时前
SpringBoot+Vue实战:打造企业级在线文档管理系统
vue.js·spring boot·后端
Rust研习社10 小时前
使用 Axum 构建高性能异步 Web 服务
开发语言·前端·网络·后端·http·rust
0xDevNull11 小时前
Spring Boot 自动装配:从原理到实践
java·spring boot·后端
IT_陈寒11 小时前
SpringBoot配置加载顺序把我坑惨了
前端·人工智能·后端
Moment11 小时前
面试官:给 llm 传递上下文,有哪几个身份 role ❓❓❓
前端·后端·面试
snakeshe101011 小时前
SpringBoot 多人协作平台实战(5):从零开始集成 MyBatis ORM 连接 MySQL 数据库
后端
Cry丶12 小时前
架构师实战:Spring Authorization Server 落地企业级“无感” SSO(附设计映射与源码级接口剖析)
spring·spring security·oauth2.0·authorization·sso·无感登录
SamDeepThinking12 小时前
中小团队需要一个资源微服务
后端·微服务·架构