1 of 22

Google App Engine

Scaling Config

GCPUG Admin

Google Developers Expert

Mercari / Merpay Solution Team

@sinmetal

https://goo.gl/Xnz3XA

https://gcpug.jp

2 of 22

App Engine Components

2

Application

Service

Service

Version

Version

Version

Version

Instance

Instance

Instance

https://gcpug.jp

3 of 22

App Engine Service

3

https://gcpug.jp

4 of 22

App Engine Version

4

https://gcpug.jp

5 of 22

App Engine Architecture

5

Google Datacenter

App Engine Services

Google

Frontend

App Engine

Frontend

Static Server

Pending Request Queue

App Server

Datastore

Memcache

Task Queue

Search

URL Fetch

Socket

自分のDeployしたApplicationが動いている場所

https://gcpug.jp

6 of 22

Scaling Config

  • Automatic Scaling
    • Request数に合わせて自動でインスタンスの追加、削除を行う設定
  • Basic Scaling
    • Request数に合わせて自動でインスタンスの追加、削除を行うが、インスタンスの最大数を事前に決めておく設定
  • Manual Scaling
    • Deploy時に指定した数のインスタンスが常時立ち上がるだけのシンプルな構成

6

https://gcpug.jp

7 of 22

Frontend , Backend

  • Frontend
    • エンドユーザからのリクエストを受け取る
    • レスポンスをすばやく返す前提なので、リクエスト処理可能時間が短い
  • Backend
    • バッチ処理など裏でやるシステム的な処理

7

https://gcpug.jp

8 of 22

Scaling Config

  • Automatic Scaling
    • Frontend
  • Basic Scaling
    • Backend
  • Manual Scaling
    • Backend

8

https://gcpug.jp

9 of 22

Automatic Scaling

  • target_cpu_utilization: 0.6 # default value
  • target_throughput_utilization: 0.6 # default value
  • max_instances: 5
  • min_instances:0
  • min_idle_instances: 0
  • max_idle_instances: automatic # default value
  • min_pending_latency: 30ms # default value
  • max_pending_latency: automatic
  • max_concurrent_requests: 80

9

https://gcpug.jp

10 of 22

Resident Instanceの消滅

No more resident instances in auto scaling. Previously, if you used the min_idle_instances setting, the minimum idle instances were labelled as Resident in the Cloud Console, with the remainder of the instances labelled as Dynamic. The new scheduler simply labels all instances as Dynamic with auto scaling. However, the underlying behavior remains similar to previous behavior. If you use min_idle_instances and enable warmup requests, you will see at least that many dynamic instances running even during periods with no traffic.

https://cloud.google.com/appengine/docs/standard/go/release-notes?hl=en

10

https://gcpug.jp

11 of 22

Resident Instanceの消滅

11

https://gcpug.jp

12 of 22

min_idle_instancesの仕様変更

    • Resident Instanceの数を指定する機能
    • warmup requestと一緒に使う。warmup requestが完了したインスタンスが指定した台数、予約された状態となる

12

https://gcpug.jp

13 of 22

min_instancesの追加

  • リクエストが無くても常時立ち上がっているインスタンスの数
    • Dynamic Instanceなので、min_instancesたちでリクエストがさばける場合はさばく

13

https://gcpug.jp

14 of 22

min_instances, min_idle_instances 両方指定

  • min_instances : 5
  • min_idle_instances : 3
    • リクエストを処理するInstanceが5つ立ち上がる
    • warmupを済ませたInstanceが3つ予約される
    • Billed Instanceとしては8つ

14

https://gcpug.jp

15 of 22

min_instances, min_idle_instances 両方指定

15

https://gcpug.jp

16 of 22

min_instances, min_idle_instances 両方指定

16

暇だから予約していた

インスタンスを解放した?

https://gcpug.jp

17 of 22

pending_latency?

  • min_pending_latency
    • pending request queueの中で少なくとも待つ時間
  • max_pending_latency
    • pending request queueの中で我慢できる最大時間

17

https://gcpug.jp

18 of 22

App Engine Request Processing Flow

18

https://gcpug.jp

19 of 22

Basic Scaling

  • max_instances: 11
  • idle_timeout: 10m

19

https://gcpug.jp

20 of 22

Manual Scaling

  • instances: 5

20

https://gcpug.jp

21 of 22

GCPUG Slack

#g-app-engine_ja

21

https://gcpug.jp

22 of 22

Resources

22

https://gcpug.jp