[Oracle Cloud] Object Storageのマルチパートアップロード機能を試してみた

本記事の目的

前回の記事では、OCI CLIを利用したObject Storage の基本的な操作手順について紹介しました。

マニュアルに記載の通り、Object Storageではマルチパート・アップロード機能が提供されており、サイズの大きなファイルを分割して処理することで、アップロードに費やす時間を短縮できます。

The Oracle Cloud Infrastructure Object Storage service supports multipart uploads for more efficient and resilient uploads, especially for large objects. You can perform multipart uploads using the API, the Java SDK, or the Command Line Interface (CLI), but not the Console. With multipart uploads, individual parts of an object can be uploaded in parallel to reduce the amount of time you spend uploading. Multipart uploads performed through the API can also minimize the impact of network failures by letting you retry a failed part upload instead of requiring you to retry an entire object upload.

目安として、100MiB以上のファイルではマルチパート・アップロードで処理すると良いようです。

Multipart uploads can accommodate objects that are too large for a single upload operation. Oracle recommends that you perform a multipart upload to upload objects larger than 100 MiB. The maximum size for an uploaded object is 10 TiB. Object parts must be no larger than 50 GiB. For very large uploads performed through the API, you have the flexibility of pausing between the uploads of individual parts, and resuming the upload as your schedule and resources allow.

というわけで、本記事では該当機能の利用手順や、処理時間への影響について確認してみます。

 

 

検証結果

基本操作

OCI CLI Command Referenceに記載の通り、オブジェクトサイズが分割サイズ(デフォルト:128MiB)以上の場合には、自動的にマルチパート・アップロードで処理されます。

If the object is larger than –part-size, it will be uploaded as multiple parts (the default part size is 128 MiB)

つまり、例えば1GBのファイルを用意して、前回の記事と同様にアップロードするだけで、自動的に8分割のマルチパート・アップロードがされるはずです。

実際に試してみます。

 

・検証用ファイル(1GB)作成

[opc@dbvmee ~]$ dd if=/dev/zero of=/tmp/dummy_big.dmp bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 13.2231 s, 79.3 MB/s

[opc@dbvmee ~]$ ls -l /tmp/dummy_big.dmp
-rw-rw-r-- 1 opc opc 1048576000 Jan 27 01:24 /tmp/dummy_big.dmp

 

・oci os object putでアップロード

参考までに時間も計測してみました。

[opc@dbvmee ~]$ time oci os object put -bn test-bucket01 --file /tmp/dummy_big.dmp
Upload ID: ce6581b8-a812-2e3f-0501-374b8f05b9f1
Split file into 8 parts for upload.★
Uploading object [####################################] 100%
{
"etag": "8066FFFA3A84CF24E053424BC00AFE1A",
"last-modified": "Sun, 27 Jan 2019 01:31:14 GMT",
"opc-multipart-md5": "XL33HVbpOwkyd+JY0YSxPg==-8"
}

real 0m19.396s
user 0m12.363s
sys 0m4.288s

⇒「Split file into 8 parts for upload.」で分かる通り、デフォルトの128MiBで分割されてアップロードされた模様。

念のため、3回ほど同じコマンドで処理時間を計測(–forceで上書き)。

— 2回目
real 0m21.618s
user 0m11.917s
sys 0m3.391s

— 3回目
real 0m20.461s
user 0m12.475s
sys 0m4.446s

 

・アップロード結果確認

[opc@dbvmee ~]$ oci os object list -bn test-bucket01 --output table
+----------------------------+-----------------+------------+----------------------------------+
| md5 | name | size | time-created |
+----------------------------+-----------------+------------+----------------------------------+
| XL33HVbpOwkyd+JY0YSxPg==-8 | dummy_big.dmp | 1048576000 | 2019-01-27T01:31:14.756000+00:00 |
+----------------------------+-----------------+------------+----------------------------------+
prefixes: []

 

・ダウンロード確認

[opc@dbvmee ~]$ time oci os object get -bn test-bucket01 --name "dummy_big.dmp" --file /tmp/download_dummy_big.dmp
Downloading object [####################################] 100%

real 0m25.934s
user 0m7.435s
sys 0m5.131s

⇒アップロードよりも若干遅い?

 

・ファイル一致確認

[opc@dbvmee ~]$ ls -l /tmp/download_dummy_big.dmp /tmp/dummy_big.dmp
-rw-rw-r-- 1 opc opc 1048576000 Jan 27 01:34 /tmp/download_dummy_big.dmp
-rw-rw-r-- 1 opc opc 1048576000 Jan 27 01:24 /tmp/dummy_big.dmp

⇒ファイルサイズ一致

[opc@dbvmee ~]$ md5sum /tmp/dummy_big.dmp /tmp/download_dummy_big.dmp
e5c834fbdaa6bfd8eac5eb9404eefdd4 /tmp/dummy_big.dmp
e5c834fbdaa6bfd8eac5eb9404eefdd4 /tmp/download_dummy_big.dmp

⇒MDハッシュでも一致を確認

 

マルチパート・アップロード処理の無効化

–no-mulipartオプションを指定することで、マルチパート・アップロードの無効化が可能

If the –no-multipart flag is specified, the object will be uploaded as a single part regardless of size (specifying –no-multipart when uploading from STDIN will result in an error)

先ほどと同じファイルを、–no-mulipartオプション付で実行して処理時間の差異を確認してみます。

[opc@dbvmee ~]$ time oci os object put -bn test-bucket01 --file /tmp/dummy_big.dmp --name no-multi_dummy_big.dmp --no-multipart
Uploading object [####################################] 100%
{
"etag": "8066FFFA66B7CF26E053424BC00A059A",
"last-modified": "Sun, 27 Jan 2019 01:45:24 GMT",
"opc-content-md5": "5cg0+9qmv9jqxeuUBO791A=="
}

real 0m29.624s
user 0m12.343s
sys 0m2.073s

⇒マルチパート処理と比べて、10秒ほど遅くなった。

念のため、3回ほど同じコマンドで処理時間を計測(–forceで上書き)。

— 2回目
real 0m27.479s
user 0m12.005s
sys 0m1.731s

— 3回目
real 0m27.934s
user 0m12.329s
sys 0m1.819s

⇒平均して遅い。

 

 

マルチパート・アップロード効果検証

最後に、ファイルサイズを10GBに増やして、いくつかのオプションパターンでマルチパート・アップロードによる処理時間の差異を確認してみます。

 

・検証用の10GBファイル作成

[opc@dbvmee ~]$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroupSys-LogVolRoot
35993216 34142324 0 100% /
tmpfs 7567052 1396736 6170316 19% /dev/shm
/dev/sda2 1397440 79180 1229224 7% /boot
/dev/sda1 496672 276 496396 1% /boot/efi
/dev/sdc 206293688 28662584 167128960 15% /u01
/dev/asm/commonstore-494
5242880 399984 4842896 8% /opt/oracle/dcs/commonstore

[opc@dbvmee u01]$ sudo su -
[root@dbvmee ~]# mkdir /u01/work

[root@dbvmee ~]# chown opc:opc /u01/work
[root@dbvmee ~]# exit
logout
[opc@dbvmee u01]$ dd if=/dev/zero of=/u01/work/10gb.dmp bs=1M count=10000
10000+0 records in
10000+0 records out
10485760000 bytes (10 GB) copied, 100.587 s, 104 MB/s

[opc@dbvmee u01]$ ls -l /u01/work/10gb.dmp
-rw-rw-r-- 1 opc opc 10485760000 Jan 27 07:46 /u01/work/10gb.dmp

 

・マルチパート・アップロード無効化した場合(–no-multipartを指定)

[opc@dbvmee ~]$ time oci os object put -bn test-bucket01 --file /u01/work/10gb.dmp --no-multipart --force
Uploading object [####################################] 100%
{
"etag": "806C575D59A81921E0538225C00A6C44",
"last-modified": "Sun, 27 Jan 2019 07:59:13 GMT",
"opc-content-md5": "JvVgJKw5zcVLIoggEH8EDQ=="
}

real 4m47.068s
user 2m1.248s
sys 0m31.431s

 

・デフォルトでの実行(128MiB分割でのマルチパートアップロード)

[opc@dbvmee ~]$ time oci os object put -bn test-bucket01 --file /u01/work/10gb.dmp --force
Upload ID: 3d2ac32b-4146-095e-6144-3b3a747a340f
Split file into 79 parts for upload.
Uploading object [####################################] 100%
{
"etag": "806CC4F6C4757E2FE0538225C00AFAD7",
"last-modified": "Sun, 27 Jan 2019 08:03:29 GMT",
"opc-multipart-md5": "gP3TzEX5IeffhsPTTXdlzA==-79"
}

real 3m33.495s
user 2m1.863s
sys 1m4.935s

⇒マルチパート・アップロード無効化時に比べて1分以上も早い

 

・分割単位を1000MBとしてアップロード

[opc@dbvmee ~]$ time oci os object put -bn test-bucket01 --file /u01/work/10gb.dmp --part-size 1000 --force
Upload ID: 8010bf75-f431-3de5-c821-3a8c725e09da
Split file into 10 parts for upload.
Uploading object [####################################] 100%
{
"etag": "806C5BA580441B53E0538225C00AA648",
"last-modified": "Sun, 27 Jan 2019 08:08:54 GMT",
"opc-multipart-md5": "BzwCLeSluoZsNWogUDjiFg==-10"
}

real 4m17.898s
user 1m58.306s
sys 1m7.772s

⇒デフォルト実行よりも遅くなった。

 

・分割単位を1000MB、かつ、パラレル度を10としてアップロード(parallel-upload-count=10を指定)

[opc@dbvmee ~]$ time oci os object put -bn test-bucket01 --file /u01/work/10gb.dmp --part-size 1000 --parallel-upload-count 10 --force
Upload ID: 5e59bfaa-e083-b066-2696-1a3405b067f8
Split file into 10 parts for upload.
Uploading object [####################################] 100%
{
"etag": "806C8D652C3E410EE0538225C00A8C99",
"last-modified": "Sun, 27 Jan 2019 08:24:33 GMT",
"opc-multipart-md5": "BzwCLeSluoZsNWogUDjiFg==-10"
}

real 3m24.112s
user 2m19.522s
sys 1m40.590s

⇒デフォルト実行と同程度まで改善

 

参考)この処理実行中のvmstat

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
10 0 364212 805208 9528 10606280 0 0 217 133 31222 40653 60 40 0 0 0
14 0 364212 779144 9696 10609304 0 0 635 138 33304 39497 56 43 0 0 0
13 0 364212 1015996 9776 10330828 0 0 66162 147 23830 33105 58 41 0 0 0
5 10 364212 823852 9756 10476568 0 0 103735 192 11756 15758 66 31 0 2 0
10 1 364212 742548 9564 10623136 0 0 91243 160 14980 20265 62 38 0 0 0
14 0 364212 1042204 9596 10321996 0 0 2419 89 32449 41452 56 44 0 0 0
11 0 364212 1018756 9668 10322912 0 0 197 88 31120 35915 60 40 0 0 0
8 0 364212 1005816 9752 10359604 0 0 7388 170 29662 31749 62 37 0 0 0

⇒負荷高すぎ。ocpuを増やしたら、もっと早くなるかも?(検証環境のOCPUは1個だけ)

 

・ダウンロード時間も確認(まずはデフォルト)

[opc@dbvmee ~]$ time oci os object get -bn test-bucket01 --name "10gb.dmp" --file /u01/work/download_10gb.dmp
Downloading object [####################################] 100%

real 3m41.591s
user 0m58.983s
sys 0m51.177s

 

・マルチパートダウンロード

OCI CLI Command Referenceの記載より、getの場合はデフォルトではマルチパート・ダウンロードにはならない模様。

–multipart-download-threshold [integer range]
Objects larger than this size (in MiB) will be downloaded in multiple parts. The minimum allowable threshold is 128 MiB.

–part-size [integer range]
Part size (in MiB) to use when downloading an object in multiple parts. The minimum allowable size is 128 MiB.

multipart-download-threshold=128(MiB)とpart-size=128(MiB)を指定して、マルチパートダウンロードを試してみる。

[opc@dbvmee ~]$ time oci os object get -bn test-bucket01 --name "10gb.dmp" --file /u01/work/download_10gb.dmp --multipart-download-threshold 128 --part-size 128
Downloading object [###################-----------------] 52% 0d 00:02:32

real 2m59.769s
user 1m23.905s
sys 1m41.625s

⇒デフォルト実行の場合よりも、40秒ほど早くなった。

 

おまけ:検証用バケット削除

[opc@dbvmee ~]$ oci os object list -bn test-bucket01 --output table --all
+-----------------------------+------------------------+-------------+----------------------------------+
| md5 | name | size | time-created |
+-----------------------------+------------------------+-------------+----------------------------------+
| BzwCLeSluoZsNWogUDjiFg==-10 | 10gb.dmp | 10485760000 | 2019-01-27T07:54:28.002000+00:00 |
| XL33HVbpOwkyd+JY0YSxPg==-8 | dummy_big.dmp | 1048576000 | 2019-01-27T07:11:33.904000+00:00 |
| 5cg0+9qmv9jqxeuUBO791A== | no-multi_dummy_big.dmp | 1048576000 | 2019-01-27T07:11:42.828000+00:00 |
+-----------------------------+------------------------+-------------+----------------------------------+
prefixes: []
[opc@dbvmee ~]$ oci os object delete -bn test-bucket01 --name 10gb.dmp
Are you sure you want to delete this resource? [y/N]: y
[opc@dbvmee ~]$ oci os object delete -bn test-bucket01 --name dummy_big.dmp
Are you sure you want to delete this resource? [y/N]: y
[opc@dbvmee ~]$ oci os object delete -bn test-bucket01 --name no-multi_dummy_big.dmp
Are you sure you want to delete this resource? [y/N]: y

・バケットの削除

[opc@dbvmee ~]$ oci os bucket delete -bn test-bucket01
Are you sure you want to delete this resource? [y/N]: y
[opc@dbvmee ~]$ oci os bucket list
[opc@dbvmee ~]$

 

 

サマリー

  • OCI CLIでのObject Storage操作では、マルチパートアップロード機能が利用可能
  • アップロード(put)の場合、デフォルトで128MiB単位のマルチパートアップロードが有効
  • ダウンロード(get)の場合、–part-size オプションなどを利用して有効化が必要
    –part-size オプションで、分割サイズ単位を指定する

環境によるが、マルチパート・アップロード/ダウンロード機能は処理時間の改善に有効。

 

参考情報

・マニュアル「Managing Buckets」
https://docs.cloud.oracle.com/iaas/Content/Object/Tasks/managingbuckets.htm

・マニュアル「OCI CLI Command Reference」
https://docs.cloud.oracle.com/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/os.html

スポンサードリンク

Be the first to comment

Leave a Reply

Your email address will not be published.


*