Top Banner
Cloud Onr Cloud OnAir Cloud OnAir 2018 3 15 放送 e-Learning 補助資料 アプリケーションにフォーカス!ビジネスに直結す る開発の極意をご紹介します。
29

[Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Mar 16, 2018

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud Onr

Cloud OnAir

Cloud OnAir

2018 年 3 月 15 日 放送 e-Learning 補助資料

アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。

Page 2: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

はじめに

2

クラウドの最適化(開発)についてご紹介します。

開発

マネージドサービス

自動化

Page 3: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

(再掲)構築 ~ 計測 ~ 学習のフィードバックループ

アイディア

製品データ

構築

計測

学習

構築 ~ 計測 ~ 学習のフィードバック

ループを短くすることで、

ユーザのフィードバックを得ながら、

本当に必要なものを高速に開発できる

Page 4: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

想定シナリオ

ログ収集

Logging

アプリサーバ

App Engine

DWHBigQuery

CloudDatalab

Data Studio

GoogleSheets

Webサイトのアクセス数を増加させる施

策を検討中。

2案について、フィードバックをもとに最終

決定を行う。

GCPにおける構築 ~ 計測 ~ 学習の

フィードバックループを、サンプルアプリ

を通じて学習しましょう!

Page 5: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 1. 構築 〜 アプリケーションをデプロイする 〜

1. アプリケーションを開発

2. ローカル環境で動作確認

3. version1 をデプロイ

4. アプリケーションを修正

5. version 2をデプロイ

ログ収集

Logging

アプリサーバ

App Engine

Page 6: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 2. 計測 〜 計測データをデータ分析基盤に収集する 〜

1. アクセスをversion1, 2に振り分ける

2. (ログを収集する)

3. Stackdriverでログを確認

4. BigQueryにログをexportログ収集

Logging

アプリサーバ

App Engine

DWHBigQuery

Page 7: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 3. 学習 〜 データから学びを得る 〜

1. BigQuery でログを解析

2. Data Studio でログを解析

3. version 2 を全体にリリース

ログ収集

Logging

アプリサーバ

App Engine

DWHBigQuery

CloudDatalab

Data Studio

GoogleSheets

Page 8: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Cloud OnAir

まとめ

Page 9: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

まとめ

9

開発を最適化するためにクラウドならではの

機能を使いましょう

開発

マネージドサービス

自動化

分析基盤

Page 10: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Cloud OnAir

本日の手順

Page 11: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 1. アプリver.1 の作成手順 その1

11

● Cloud Shellを起動

コンソール画面の右上にあるアイコンをクリックし、Cloud Shellを起動する。

ブラウザの下部に、コンソール画面が表示される

Page 12: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 1. アプリver.1 の作成手順 その2

12

● main.py を作成

# encoding: utf-8

import webapp2

class MainPage(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.write(u"Ver. 1")

app = webapp2.WSGIApplication([ ('/', MainPage),], debug=True)

Page 13: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 1. アプリver.1 の作成手順 その3

13

● app.yaml を作成

runtime: python27api_version: 1threadsafe: true

handlers:- url: /.* script: main.app

Page 14: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 1. アプリver.1 の作成手順 その4

$ dev_appserver.py .

● 以下のコマンドを実行し、Cloud Shell内でアプリを起動

● 「ポート上でプレビュー 8080」をクリックし、アプリを確認

Cloud Shellの右上にある「ポート上でプレビュー 8080」をクリックし、アプリをプレビュー。

ブラウザで、アプリがプレビューされる

Page 15: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 1. アプリver.1 の作成手順 その5

$ gcloud app deploy --version v1

● 以下のコマンドを実行し、アプリver. 1をデプロイ

--version : デプロイしたアプリのバージョン名を指定

※ 初回デプロイ時は、リージョンを選択する必要あり。

 東京リージョン(asia-northeast1)を推奨。

Page 16: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 1. アプリver.1 の作成手順 その6

● Cloud Consoleから、デプロイしたアプリを確認

○ 「App Engine」→「バージョン」を選択

○ v1を選択

Page 17: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 1. アプリver.2 の作成手順 その1

17

● main.py を修正

# encoding: utf-8

import webapp2

class MainPage(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.write(u"Ver. 2")

app = webapp2.WSGIApplication([ ('/', MainPage),], debug=True)

# 修正箇所

Page 18: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 1. アプリver.2 の作成手順 その2

$ gcloud app deploy --version v2 --no-promote

● 以下のコマンドを実行し、アプリver. 2をデプロイ

--no-promote : デプロイしたアプリにトラフィックを割り当てない

--version : デプロイしたアプリのバージョン名を指定

Page 19: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 2. トラフィックの分割

● トラフィックを分割

○ 「トラフィックを分割」を選択

○ トラフィック分割の基準を”ランダム”に指定

○ トラフィック割り当てを”20%”に指定

○ 「保存」を選択

Page 20: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 2. ログの確認

● Stackdriver Loggingで、ログを確認

○ 「Logging」にて、”GAEアプリケーション”でログを絞り込み

Page 21: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 2. BigQueryにログをエクスポート

● Loggingにて、BigQueryにログをエクスポートする設定を追加

○ 「エクスポートを作成」を選択

○ “新しいBigQueryデータセットを作成”を選択し、名前を入力

Page 22: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 3. BigQueryでログを解析

SELECT resource.labels.version_id, COUNT(resource.labels.version_id) AS totalFROM [<ProjectID>:CloudOnAir.appengine_googleapis_com_request_log_20180308]GROUP BY resource.labels.version_id

● BigQueryでログを解析

○ “CloudOnAir”データセット -> “appengine_googleapis_***”テーブルを選択

○ 「Query Editor」で以下のクエリを実行

Page 23: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 3. Data Studioでログを解析 その1

● Data Studioを表示

https://datastudio.google.com/

「新しいレポートの開始」をクリック

Page 24: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 3. Data Studioでログを解析 その2

2. 「新しいデータソースを作成」をクリック

1. レポートのタイトルを変更する

Page 25: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 3. Data Studioでログを解析 その3

1. BigQueryを選択

2. (初めての場合のみ)承認ボタンをクリックしてアクセス権を許可する

Cloud OnAir

Page 26: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 3. Data Studioでログを解析 その4

Page 27: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 3. Data Studioでログを解析 その5

Page 28: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 3. Data Studioでログを解析 その6

「挿入」から、自由な組み合わせで分析・レポート出力

Page 29: [Cloud OnAir] アプリケーションにフォーカス!ビジネスに直結する開発の極意をご紹介します。(e-Learning) 2018年3月15日 放送

Cloud OnAir

Step 3. アプリver. 2を全体にリリース

● App Engineから、ver. 2を全体にリリース

○ 「App Engine」→「バージョン」を選択

○ 「トラフィックの移行」を選択