LoginSignup
8
3

More than 5 years have passed since last update.

GCRでイメージをgcr.ioに置いて、各リージョンでダウンロード時間を測定してみた

Last updated at Posted at 2019-03-06

はじめに

  • GCRって、リージョン意識しないの?各リージョンにインスタンス立ててみて、docker pullの時間を測定してみました
  • 利用ホスト場所は gcr.io (※ あとで補足)
    • 以下、公式ドキュメントより
    • > gcr.io は現時点では米国でイメージをホストしていますが、今後はロケーションが変更される可能性があります。
  • コンテナイメージは2GBのファイルを突っ込んだやつです
  • ※ 関係ないはずですが、pushはTokyoから行いました

image.png

結論

  • リージョン間でダウンロード時間は、1%程度しか差がありませんでした。 (数secくらい違うかという予想であったが)
  • また、ダウンロード時間はそれぞれバラツキも少ない測定結果となりました

image.png

Trial Num oregon london tokyo
1 27.1 28.5 28
2 28 27 27.7
3 27.3 27.6 27.9
4 27.3 27.4 27.9
5 27.3 27.5 28.2
Ave. 27.4 27.6 27.94

考察

GCR で利用できるリージョン

高速で可用性の高いアクセス
世界各地域に広がる非公開リポジトリを使用することで、世界中どこでも最適なレスポンス時間を実現できます。ヨーロッパ、アジア、米国の中で、自社の Compute インスタンスに近い場所にイメージを保存し、Google の高パフォーマンス グローバル ネットワークにアクセスすることで、迅速にデプロイできます。

  • 実はホストの場所は以下を選ぶことができました。(知らなかった)

    • gcr.io は現時点では米国でイメージをホストしていますが、今後はロケーションが変更される可能性があります。
    • us.gcr.io は米国でイメージをホストしますが、その場所は、gcr.io によってホストされるイメージからは独立したストレージ バケットです。
    • eu.gcr.io は、欧州連合でイメージをホストします。
    • asia.gcr.io は、アジアでイメージをホストします。
  • gcr.io は 米国 にホストされていたのですね。

リージョンを指定した場合どうなるか

  • となれば試してみたくなります。 追加検証です。
  • asia.gcr.io を利用して、Tokyoリージョン からダウンロードしてみます

image.png

# time docker pull asia.gcr.io/michelle214/gcr-test:2gb
  • 結果.... 優位な差はありませんでした。(1%程度の差)

image.png

Trial Num tokyo (from asia.gcr.io)
1 28.1
2 27.5
3 27.5
4 27.4
5 27.5
Ave. 27.6

まとめ

  • とりあえず、gcr.io を使っておくでよさそう!

補足

  • ちなみに、やっぱりきになってしまったので、Londonからだけ、asia.gcr.io からダウンロードしてみました
  • ..若干..? いやでも2%くらいの差ですね。 image.png

image.png

Trial Num london (from asia.gcr.io)
1 28.8
2 27.9
3 27.9
4 27.9
5 28.1
Ave. 28.12

検証条件 (参考までに)

Server

Instance Region Machine type OS Docker version
Oregon us-west1-a n1-standard-1 CentOS7 18.09.3
London europe-west2-a n1-standard-1 CentOS7 18.09.3
Tokyo asia-northeast1-a n1-standard-1 CentOS7 18.09.3

Docker pull

  • timeで測定しました
# time docker pull gcr.io/<myproject>/gcr-test:2gb
2gb: Pulling from <myproject>/gcr-test
48ecbb6b270e: Pull complete 
a1dc9d380f7a: Pull complete 
Digest: sha256:26c924244b387232b2a4eec5bb3a25184ca9f6e8db6e6ddbb008370ed5a41189
Status: Downloaded newer image for gcr.io/<myproject>/gcr-test:2gb

real    0m28.023s
user    0m0.325s
sys     0m0.094s
  • imageは毎回削除で5回繰り返し
# docker images -q | xargs docker rmi -f

準備の手順メモ

Docker Image

FROM alpine:3.7

COPY 2GB-file /

ENTRYPOINT ["/bin/sh", "-c", "while true; do echo hello world; sleep 1; done"]
  • 2GBのファイル作った
# dd if=/dev/zero of=2GB-file bs=1024k count=2000
# ll -h
total 2.0G
-rw-r--r--. 1 root root 2.0G Mar  6 14:20 2GB-file
-rw-r--r--. 1 root root  125 Mar  6 14:18 Dockerfile
  • docker build
# docker build -t gcr-test:2gb .
Sending build context to Docker daemon  2.097GBBB
Step 1/3 : FROM alpine:3.7
3.7: Pulling from library/alpine
48ecbb6b270e: Pull complete 
Digest: sha256:4013ae48be82862082484fc3cc68120d42b752c156abad5fd3877543116994ce
Status: Downloaded newer image for alpine:3.7
 ---> bc8fb6e6e49d
Step 2/3 : COPY 2GB-file /
 ---> fc9d4e7b87bc
Step 3/3 : ENTRYPOINT ["/bin/sh", "-c", "while true; do echo hello world; sleep 1; done"]
 ---> Running in 924f15d78ebf
Removing intermediate container 924f15d78ebf
 ---> 4befdff419f4
Successfully built 4befdff419f4
Successfully tagged gcr-test:2gb
  • 確認
# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
gcr-test            2gb                 4befdff419f4        About a minute ago   2.1GB
alpine              3.7                 bc8fb6e6e49d        4 weeks ago          4.21MB

docker push

  • login
# gcloud auth configure-docker
The following settings will be added to your Docker config file 
located at [/root/.docker/config.json]:
 {
  "credHelpers": {
    "gcr.io": "gcloud", 
    "us.gcr.io": "gcloud", 
    "eu.gcr.io": "gcloud", 
    "asia.gcr.io": "gcloud", 
    "staging-k8s.gcr.io": "gcloud", 
    "marketplace.gcr.io": "gcloud"
  }
}

Do you want to continue (Y/n)?  y

Docker configuration file updated.
  • tag
# docker tag gcr-test:2gb gcr.io/<myproject>/gcr-test:2gb
  • push
    • pushはtokyo regionのサーバからやりました
# docker push gcr.io/<myproject>/gcr-test:2gb
The push refers to repository [gcr.io/<myproject>/gcr-test]
9b76a49972c2: Pushed 
629164d914fc: Layer already exists 
2gb: digest: sha256:26c924244b387232b2a4eec5bb3a25184ca9f6e8db6e6ddbb008370ed5a41189 size: 739
  • Image確認 ちゃんとアップロードされていますね

image.png

image.png

8
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
3