SpringCloud--服务降级--高并发测试卡顿

  1. Jmeter高并发测试:
    1.  

    2. http://localhost:8001/payment/hystrix/ok/1 :秒回

    3. http://localhost:8001/payment/hystrix/timeout/1 :处理三秒钟
    4.  

    5.  

       

  2. 订单微服务调用支付服务

    1. package com.model.service;
      
      import org.springframework.cloud.openfeign.FeignClient;
      import org.springframework.stereotype.Component;
      import org.springframework.web.bind.annotation.GetMapping;
      import org.springframework.web.bind.annotation.PathVariable;
      import org.springframework.web.bind.annotation.RequestMapping;
      
      /**
       * @Description:测试类
       * @Author: 张紫韩
       * @Crete 2021/9/11 23:46
       */
      @Component
      @FeignClient("springcloud001-provider-payment")
      @RequestMapping("/payment")
      public interface OrderService {
      
          @GetMapping("/hystrix/ok/{id}")
          public String paymentInfo_ok(@PathVariable("id")Integer id);
          @GetMapping("/hystrix/timeout/{id}")
          public String paymentInfo_timeout(@PathVariable("id")Integer id);
      }
    2. package com.model.controller;
      
      import com.model.service.OrderService;
      import org.springframework.stereotype.Controller;
      import org.springframework.web.bind.annotation.GetMapping;
      import org.springframework.web.bind.annotation.PathVariable;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RestController;
      
      import javax.annotation.Resource;
      
      /**
       * @Description:测试类
       * @Author: 张紫韩
       * @Crete 2021/9/11 23:46
       */
      @RestController
      @RequestMapping("/consumer")
      public class OrderController {
      
          @Resource
          private OrderService orderService;
      
          @GetMapping("/payment/hystrix/ok/{id}")
          public String paymentInfo_ok(@PathVariable("id")Integer id){
              return orderService.paymentInfo_ok(id);
          }
      
          @GetMapping("/payment/hystrix/timeout/{id}")
          public String paymentInfo_timeout(@PathVariable("id")Integer id){
              return orderService.paymentInfo_timeout(id);
          }
      
      }
    3.  

  3. 问题:

  4. 解决:

    1.  

       

       

    2.  

        

posted @ 2021-09-12 00:31  张紫韩  阅读(93)  评论(0编辑  收藏  举报