aws s3 mv 命令正在影响性能
aws s3 mv command is impacting the performance
我们正在实施一个近乎实时的项目,我们将原始数据放入 S3 文件夹中。我们每 5 分钟收到近 2000 个文件。
作为要求的一部分,我们必须 move/archive 将文件从 S3 转移到 S3 中的另一个文件夹。我们必须只移动那些早于 10 分钟的文件。目前使用以下脚本,我们每 5 分钟安排一次。但有时 运行.
需要 5 分钟以上
我们是否可以通过使用 s3cmd 等任何其他功能来提高性能?
#!/bin/bash
# This script archives the files in S3 folder older than 10mins And is scheduled for every 5 mins
dt=`date +"%Y%m%d"`
s3_input=s3://bucket/input/
s3_archive=s3://bucket/archive/$dt/
olderThan=`date --date "10 minutes ago" +%s`
s3files=""
#loop for all the files in the input path
aws s3 ls $s3_input| grep "<string starts with>" |( while read -r line;
do
#Get creation date and timestamp of the S3 file
createDate=`echo $line | awk {'print " "'}`
createDate=`date -d "$createDate" +%s`
if [[ $createDate -lt $olderThan ]]; then
fileName=`echo $line | awk {'print '}`
#s3files="$s3files --include $fileName"
aws s3 mv $s3_input$fileName $s3_archive$fileName
fi
done
#if [[ ! -z $s3files ]]; then
#aws s3 mv $s3_input $s3_archive --recursive --exclude "*" ${s3files}
#fi
)
谢谢
我不知道你任务的所有参数,但我建议这个方案:
创建消息可见延迟为 10 分钟的 SQS 队列
将 SQS 订阅到 S3 存储桶事件,因此每个对象创建事件都会在 SQS 中创建消息
将 Lambda 函数订阅到此队列,编写代码将对象移动到您的存档位置
这更易于管理,您不需要大量基础设施来支持,因为 lambda 是无服务器的。
我们正在实施一个近乎实时的项目,我们将原始数据放入 S3 文件夹中。我们每 5 分钟收到近 2000 个文件。
作为要求的一部分,我们必须 move/archive 将文件从 S3 转移到 S3 中的另一个文件夹。我们必须只移动那些早于 10 分钟的文件。目前使用以下脚本,我们每 5 分钟安排一次。但有时 运行.
需要 5 分钟以上我们是否可以通过使用 s3cmd 等任何其他功能来提高性能?
#!/bin/bash
# This script archives the files in S3 folder older than 10mins And is scheduled for every 5 mins
dt=`date +"%Y%m%d"`
s3_input=s3://bucket/input/
s3_archive=s3://bucket/archive/$dt/
olderThan=`date --date "10 minutes ago" +%s`
s3files=""
#loop for all the files in the input path
aws s3 ls $s3_input| grep "<string starts with>" |( while read -r line;
do
#Get creation date and timestamp of the S3 file
createDate=`echo $line | awk {'print " "'}`
createDate=`date -d "$createDate" +%s`
if [[ $createDate -lt $olderThan ]]; then
fileName=`echo $line | awk {'print '}`
#s3files="$s3files --include $fileName"
aws s3 mv $s3_input$fileName $s3_archive$fileName
fi
done
#if [[ ! -z $s3files ]]; then
#aws s3 mv $s3_input $s3_archive --recursive --exclude "*" ${s3files}
#fi
)
谢谢
我不知道你任务的所有参数,但我建议这个方案:
创建消息可见延迟为 10 分钟的 SQS 队列
将 SQS 订阅到 S3 存储桶事件,因此每个对象创建事件都会在 SQS 中创建消息
将 Lambda 函数订阅到此队列,编写代码将对象移动到您的存档位置
这更易于管理,您不需要大量基础设施来支持,因为 lambda 是无服务器的。