SpringCloud--服务降级--高并发测试卡顿
- Jmeter高并发测试:
-
-
http://localhost:8001/payment/hystrix/ok/1 :秒回
- http://localhost:8001/payment/hystrix/timeout/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); }
-
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); } }
-
-
问题:
-
解决:
-