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

相关推荐
bagadesu1 小时前
使用Docker构建Node.js应用的详细指南
java·后端
没有bug.的程序员1 小时前
Spring Cloud Gateway 性能优化与限流设计
java·spring boot·spring·nacos·性能优化·gateway·springcloud
勇哥java实战分享4 小时前
第一次用 Ollama 跑视觉模型:Qwen2.5-VL 7B 给了我一个意外惊喜
后端
码事漫谈6 小时前
从后端开发者到Agent工程师:一份系统性的学习指南
后端
码事漫谈6 小时前
后端开发如何将创新转化为专利?案例、流程与实操指南
后端
KYumii6 小时前
智慧判官-分布式编程评测平台
vue.js·spring boot·分布式·spring cloud·java-rabbitmq
小坏讲微服务7 小时前
SpringCloud零基础学全栈,实战企业级项目完整使用
后端·spring·spring cloud
humors2217 小时前
服务端开发案例(不定期更新)
java·数据库·后端·mysql·mybatis·excel
专注VB编程开发20年9 小时前
C#VB.NET中实现可靠的文件监控(新建、删除、改名、内容修改等事件的准确捕获)
spring·c#·.net·文件监控
Easonmax10 小时前
用 Rust 打造可复现的 ASCII 艺术渲染器:从像素到字符的完整工程实践
开发语言·后端·rust