首页 > 解决方案 > 上传大文件时断路器打开

问题描述

我有一个具有以下微服务架构师的现有项目。Client --> API Gateway(Spring cloud 使用 Hystrix 作为断路器) --> UploadService. 上传小文件(POST /upload/video)时一切正常。但是当文件较大时,上传时间很长,Hystrix 将打开并返回回退。

有没有人对我的案例进行过练习,或者我如何设置仅POST /upload/video在 Hystrix 上请求的超时?

标签: microservicesspring-boot

解决方案


看来您需要在 Hystric 客户端中配置更大的超时时间;在您的示例中,这是“API 网关(使用 Hystrix 作为断路器的 Spring 云)”

我想您的代码将如下所示:

HystrixCommand.Setter yourHystrixCommand; ... blah your HystrixCommand

HystrixCommandProperties.Setter hystrixCommandPropertiesSetter = HystrixCommandProperties.Setter();
hystrixCommandPropertiesSetter.withExecutionTimeoutInMilliseconds(yourDesiredTimeoutValue);
yourHystrixCommand.andCommandPropertiesDefaults(commandProperties);

这是Baeldung 对 Hystrix 的介绍

编辑:
这里的“Hystrix 客户端”是指使用 Hystrix 的客户端软件。


推荐阅读