以前紹介した方法「Linuxで指定したサイズのファイルを指定した数だけ作成する」にて、10MByteのファイルを
30個用意します。
そしてs3cmdを使い、これらのファイルを様々なパターンでS3にアップロードしてみようと思います。

まずはsyncでアップロードします。

# time s3cmd --no-progress sync ./ s3://www.suz-lab.com/tmp/
File './test-000001' stored as 's3://www.suz-lab.com/tmp/test-000001' (10485760 bytes in 0.8 seconds, 12.33 MB/s) [1 of 30]
...
File './test-000030' stored as 's3://www.suz-lab.com/tmp/test-000030' (10485760 bytes in 0.6 seconds, 18.08 MB/s) [30 of 30]
Done. Uploaded 314572800 bytes in 21.8 seconds, 13.73 MB/s

real 0m22.466s
user 0m2.535s
sys 0m0.707s

10-20MB/sなので、2、30秒かかっています。

次に一つ一つアップロードします。

# time find -name "test-*" | xargs -L1 -P1 -i s3cmd --no-progress put {} s3://www.suz-lab.com/tmp/
File './test-000030' stored as 's3://www.suz-lab.com/tmp/test-000030' (10485760 bytes in 1.1 seconds, 9.49 MB/s) [1 of 1]
...
File './test-000002' stored as 's3://www.suz-lab.com/tmp/test-000002' (10485760 bytes in 0.7 seconds, 13.79 MB/s) [1 of 1]

real 0m29.257s
user 0m5.349s
sys 0m1.698s

コマンドは変わりましたが条件は変わっていないため、やはり2、30秒かかっています。

今度は多重度を2にしてアップロードします。

# time find -name "test-*" | xargs -L1 -P2 -i s3cmd --no-progress put {} s3://www.suz-lab.com/tmp/
File './test-000030' stored as 's3://www.suz-lab.com/tmp/test-000030' (10485760 bytes in 0.6 seconds, 17.47 MB/s) [1 of 1]
...
File './test-000002' stored as 's3://www.suz-lab.com/tmp/test-000002' (10485760 bytes in 0.5 seconds, 18.92 MB/s) [1 of 1]

real 0m13.163s
user 0m5.069s
sys 0m2.002s

倍まではいきませんが、かなり短縮できています。

さらに多重度を4にしてアップロードします。

# time find -name "test-*" | xargs -L1 -P4 -i s3cmd --no-progress put {} s3://www.suz-lab.com/tmp/
File './test-000025' stored as 's3://www.suz-lab.com/tmp/test-000025' (10485760 bytes in 0.9 seconds, 11.40 MB/s) [1 of 1]
...
File './test-000002' stored as 's3://www.suz-lab.com/tmp/test-000002' (10485760 bytes in 1.4 seconds, 7.21 MB/s) [1 of 1]

real 0m9.995s
user 0m5.218s
sys 0m2.462s

先程に比べ多少速くなっていますが、少しづつ効果は薄くなっています。

最後に多重度を8にしてアップロードします。

# time find -name "test-*" | xargs -L1 -P8 -i s3cmd --no-progress put {} s3://www.suz-lab.com/tmp/
File './test-000013' stored as 's3://www.suz-lab.com/tmp/test-000013' (10485760 bytes in 0.9 seconds, 10.86 MB/s) [1 of 1]
...
File './test-000020' stored as 's3://www.suz-lab.com/tmp/test-000020' (10485760 bytes in 1.4 seconds, 7.27 MB/s) [1 of 1]

real 0m8.258s
user 0m5.215s
sys 0m2.372s

先程より多重度を上げたことで、逆に遅くなってしまいました。

上記のように、多重度を上げればアップロード時間は短縮されましたが、おそらく、EC2のタイプ等で
最も早くアップロードできる多重度は違うと思いますので、都度、適切な多重度を確認する必要が
あるかもしれません。
(上記はt1.microで実験しました)

こちらの記事はなかの人(suz-lab)監修のもと掲載しています。
元記事は、こちら