因生产环境数据量和并发量过大,Minio会出现上传超时问题
具体报错:A timeout exceeded while waiting to proceed with the request, please reduce your request
经查阅资料,有4种解决方案
查阅文献:
https://www.oomake.com/question/17229356
https://www.nuomiphp.com/t/6254af8578e87f77ee3d038c.html
https://www.hxstrive.com/subject/minio/673.htm
https://github.com/minio/minio/tree/master/docs/config#api
https://blog.csdn.net/qq_62982856/article/details/128995909
1.检查Minio代码,有使用到流的地方需要及时关闭流
- 手动关闭
try {
// 获取输入流
InputStream inputStream = minioClient.getObject(
GetObjectArgs
.builder()
.bucket(bucket)
.object(filePath)
.build()
);
// 关闭流
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
- 使用try catch自动关闭流
try (InputStream input = downloadFileStream(fileName);ByteArrayOutputStream bos = new ByteArrayOutputStream()){
//缓存
byte[] b = new byte[1024];
int n;
while ((n = input.read(b)) != -1) {
bos.write(b, 0, n);
}
//改变为byte[]
return bos.toByteArray();
}catch (Exception e) {
log.error("Minio出错",e);
}
2.检查Minio存储目录
部署单机版Minio时,假设你文件存放的目录为 a/,不要放太多的 object ,应该分开放
比如以日期,或者文件 hash 取几位建目录再把 object 放进去
因为单机版存在这样一个问题,就是如果一个文件夹 a/下面有多个 object ,你 100 万个全放 a/下面,list 性能会非常低,单机版似乎是以源文件方式直接存到磁盘的
3.部署Minio集群
集群要求:至少4个Minio服务
- 4台机器,每一台机器一个Minio,每一个Minio指定当前机器硬盘
或其它组合方式部署Minio集群,部署Minio集群前先百度一下部署集群的要求
4.优化Minio配置参数
- docker可以设置Minio环境变量来设置Minio配置
环境变量 | 单位 | 说明 |
---|---|---|
MINIO_API_REQUESTS_MAX | number | set the maximum number of concurrent requests (default: ‘0’) |
MINIO_API_REQUESTS_DEADLINE | duration | set the deadline for API requests waiting to be processed (default: ‘10s’) |
MINIO_API_CLUSTER_DEADLINE | duration | set the deadline for cluster readiness check (default: ‘10s’) |
MINIO_API_CORS_ALLOW_ORIGIN | csv | set comma separated list of origins allowed for CORS requests (default: ‘*’) |
MINIO_API_REMOTE_TRANSPORT_DEADLINE | duration | set the deadline for API requests on remote transports while proxying between federated instances e.g. “2h” (default: ‘2h’) |
MINIO_API_LIST_QUORUM | string | set the acceptable quorum expected for list operations e.g. “optimal”, “reduced”, “disk”, “strict” (default: ‘strict’) |
MINIO_API_REPLICATION_PRIORITY | string | set replication priority (default: ‘auto’) |
MINIO_API_TRANSITION_WORKERS | number | set the number of transition workers (default: ‘100’) |
MINIO_API_STALE_UPLOADS_EXPIRY | duration | set to expire stale multipart uploads older than this values (default: ‘24h’) |
MINIO_API_STALE_UPLOADS_CLEANUP_INTERVAL | duration | set to change intervals when stale multipart uploads are expired (default: ‘6h’) |
MINIO_API_DELETE_CLEANUP_INTERVAL | duration | set to change intervals when deleted objects are permanently deleted from “.trash” folder (default: ‘5m’) |
MINIO_API_DISABLE_ODIRECT | boolean | set to disable O_DIRECT for reads under special conditions. NOTE: it is not recommended to disable O_DIRECT without prior testing. (default: ‘off’) |
MINIO_API_REQUESTS_DEADLINE 和 MINIO_API_STALE_UPLOADS_EXPIRY 是我此次优化的环境变量文章来源:https://www.toymoban.com/news/detail-601264.html
文章来源地址https://www.toymoban.com/news/detail-601264.html
- 通过设置config.josn文件设置Minio配置
参考:https://github.com/minio/minio/tree/master/docs/config#api
到了这里,关于关于Minio性能优化 A timeout exceeded while waiting to proceed with the request, please reduce your request的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!