一、该问题的重现步骤是什么?
1. 上传相机拍摄的图片文件(30~80M), 发现上传速度比较慢, 上传带宽只能跑到200M左右。但是同样的文件在minio控制台上传可以跑满1G。
2. 我们拍摄的图片比较多,所以想优化一下。
3. 参数从默认值调整了一下,没有效果

看起来虚拟线程没有并行

二、你期待的结果是什么?实际看到的又是什么?
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
blade-tool 4.8.0, linux
四、请提供详细的错误堆栈信息,这很重要。
五、若有更多详细信息,请在下面提供。
自定义一个httpclient试试看呢
@Bean
public MinioClient minioClient(OssProperties ossProperties) {
Dispatcher dispatcher = new Dispatcher();
dispatcher.setMaxRequests(100);
dispatcher.setMaxRequestsPerHost(100);
OkHttpClient customHttpClient = new OkHttpClient.Builder()
.dispatcher(dispatcher)
.connectionPool(new ConnectionPool(50, 5, TimeUnit.MINUTES))
.connectTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build();
return MinioClient.builder()
.endpoint(ossProperties.getEndpoint())
.credentials(ossProperties.getAccessKey(), ossProperties.getSecretKey())
.httpClient(customHttpClient)
.build();
}每个文件相差2~3秒,效果不大
@Bean
public MinioClient minioClient(OssProperties ossProperties) {
Dispatcher dispatcher = new Dispatcher();
dispatcher.setMaxRequests(100);
dispatcher.setMaxRequestsPerHost(100);
OkHttpClient customHttpClient = new OkHttpClient.Builder()
.dispatcher(dispatcher)
.connectionPool(new ConnectionPool(50, 5, TimeUnit.MINUTES))
.connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES)
.writeTimeout(1, TimeUnit.MINUTES)
.retryOnConnectionFailure(true)
.connectionPool(new ConnectionPool(36, 5, TimeUnit.MINUTES))
.build();
return new MinioClient.Builder()
.endpoint(ossProperties.getEndpoint())
.credentials(ossProperties.getAccessKey(), ossProperties.getSecretKey())
.httpClient(customHttpClient)
.build();
}那估计从后端层面看没太大提升了,因为调用的是官方的sdk,java作为中转多了一次解析、合并、再分片,和控制台直接读取不一样。
还有一种方式安全性低一点,上传的时候不通过java接口,直接用前端js调用js的sdk进行上传,但这样会暴露minio的key,看具体取舍。
扫一扫访问 Blade技术社区 移动端