12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Replica pool で Google Compute Engine のインスタンスを一度にたくさん立てる

Last updated at Posted at 2014-09-22

漢なら Google Compute Engine 10 万ノード立てて分散レイトレーシングしたいですよね!

でも GCE の標準機能だと, 同時に 16 instances までしかインスタンス起動のリクエストを発行できません… 1 バッチ 10 秒で出来たとしてもインスタンスの起動だけでも 10 sec * 100K / 16 = 62500 sec = 17 時間半もかかってしまいます…

そこで replica pool で練習してみましょう.

残念ながら replica pool はまだプレビュー版です.
Web から Replica Pool API を有効にしておきます.
以下のように gcloud cli もアップデートして機能を有効にしておきます.

$ gcloud components update preview

以下のような感じでレプリカ(インスタンス)のタイプなどを指定するテンプレートファイル my-replica-pool-template.json を作ります.

{ "template": {
    "vmParams": {
      "machineType": "n1-standard-1",
      "baseInstanceName": "my-replica",
      "disksToCreate": [{
        "boot": "true",
        "initializeParams": {
          "sourceImage": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20131120",
          "diskSizeGb": "10"
         }
       }],
     "networkInterfaces": [{
       "network": "default",
       "accessConfigs": [{
         "type": "ONE_TO_ONE_NAT",
         "name": "External NAT"
       }]
     }]
   }
  }
}

Replica pools でインスタンスの起動

my-pool という名前で 100 インスタンス(100 replicas)立ててみます.

$ gcloud preview replica-pools --zone us-central1-a create --size 100 --template my-replica-pool-template.json my-pool

Replica pool my-pool is being created.

Web console で確認してみます!

gce-replica-pools.png

あら素敵. あっというまに 100 インスタンス立ちました. 素晴らしい.

ただし現在は 500 replicas per pool, 5 Pools per project(per project?)という制約があります.

Replica pool の削除.

delete コマンドで pool 指定で replicas の一括削除ができます.

$ gcloud preview replica-pools --zone us-central1-a delete my-pool

Cool! これでインスタンス数多く立てたい日も安心ですね!

TODO

  • レプリカに名前はランダムで付くようなので, 特定のレプリカ単位の操作をしたいときにどうするか?
  • 外部 IP 振ると大変なことになりそうなので外部 IP 振らなくても管理できる方法を探す.
12
12
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
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?