106

Cloud Native Application on DEIS by using 12 factor

Embed Size (px)

Citation preview

Page 1: Cloud Native Application on DEIS by using 12 factor
Page 2: Cloud Native Application on DEIS by using 12 factor

自己紹介

日本マイクロソフト(株)Java エバンジェリスト寺田 佳央

ハッシュタグ #てらだよしおがんばれ

Page 3: Cloud Native Application on DEIS by using 12 factor

クラウドを有効活用できすアプリケーションを実装されてますか?

Page 4: Cloud Native Application on DEIS by using 12 factor

今のアプリケーションをそのままクラウドに移行する?

Page 5: Cloud Native Application on DEIS by using 12 factor

ところで昨今話題ですが

Page 6: Cloud Native Application on DEIS by using 12 factor

マイクロサービスは必要 ?

Page 7: Cloud Native Application on DEIS by using 12 factor

モノリシック?マイクロ?

Page 8: Cloud Native Application on DEIS by using 12 factor

一般的な企業システムの実装例

顧客管理 受注管理 物流管理 売り上げ管理

商品管理 レコメンド 顧客分析 経営分析

企業システム DB

Page 9: Cloud Native Application on DEIS by using 12 factor

どんどんマイクロ・サービス化

受注管理サービス

顧客管理 DB

物流管理サービス

顧客管理 DB

Page 10: Cloud Native Application on DEIS by using 12 factor
Page 11: Cloud Native Application on DEIS by using 12 factor

マイクロサービス

いち早くサービスを提供したい

柔軟にスケールさせたい

独立したサービス作りをおこないたい

耐障害性を高めたい変更に強いシステムを

作りたいとりあえず

MSA 化が必要

Docker を導入したい

何のためのマイクロ・サービス?

Page 12: Cloud Native Application on DEIS by using 12 factor

マイクロサービス

一番だめなパターン

とりあえずMSA 化が必要

Docker を導入したい

Page 13: Cloud Native Application on DEIS by using 12 factor

マイクロサービス

いち早くサービスを提供したい

柔軟にスケールさせたい

独立したサービス作りをおこないたい

MSA でなくてもできません?

Page 14: Cloud Native Application on DEIS by using 12 factor

マイクロサービス

耐障害性を高めたい(回復性を高める)

変更に強いシステムを作りたい

MSA が有効( 寺田の所感 )

Page 15: Cloud Native Application on DEIS by using 12 factor
Page 16: Cloud Native Application on DEIS by using 12 factor

https://jaxenter.com/microservices-trends-2017-survey-133265.html

既存サービスを

マイグレーションする

新規サービスで

導入導入済み

予定なし

Page 17: Cloud Native Application on DEIS by using 12 factor

12 Factor App

Reactor Manifest

組織作り

TDD

Agile

継続的インテグレーション

Infrastructure as Code

継続的デリバリ

Page 18: Cloud Native Application on DEIS by using 12 factor

https://12factor.net/ja/

Page 19: Cloud Native Application on DEIS by using 12 factor

© 2017 Microsoft Corporation. All rights reserved.

本情報の内容(添付文書、リンク先などを含む)は、作成日時点でのものであり、予告なく変更される場合があります。

ちょっと宣伝させてください

Page 20: Cloud Native Application on DEIS by using 12 factor
Page 21: Cloud Native Application on DEIS by using 12 factor

Azure Container Service

Page 22: Cloud Native Application on DEIS by using 12 factor
Page 23: Cloud Native Application on DEIS by using 12 factor

クラウド・ネイティブなスケーラブル・アプリ開発のために

Page 24: Cloud Native Application on DEIS by using 12 factor

https://12factor.net/ja/

Page 25: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

ソースコード管理

Page 26: Cloud Native Application on DEIS by using 12 factor

ソースコード管理

Page 27: Cloud Native Application on DEIS by using 12 factor

どのようなソースコード管理 してます?

複数のモジュールを

1レポジトリで管理

Page 28: Cloud Native Application on DEIS by using 12 factor

サービス毎にレポジトリを作成しましょう

Page 29: Cloud Native Application on DEIS by using 12 factor

サービス毎の履歴管理や

把握が容易に !!

Page 30: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

どうやって実装?

Page 31: Cloud Native Application on DEIS by using 12 factor

今までの Web アプリケーション

ビジネス・ロジック

Page 32: Cloud Native Application on DEIS by using 12 factor

ビューとロジックを分離

ビジネス・ロジック

Page 34: Cloud Native Application on DEIS by using 12 factor

RESTful Web Services

JSON

Page 35: Cloud Native Application on DEIS by using 12 factor

Stateless

Page 36: Cloud Native Application on DEIS by using 12 factor

UI とバックエンド・サービスの分割

UI

Face Detect

warファイル

Emotional

UI サービス

Face Detect

Emotional

Page 37: Cloud Native Application on DEIS by using 12 factor
Page 38: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

並列処理非同期ノンブロッキング

Page 39: Cloud Native Application on DEIS by using 12 factor

同期?非同期?

Service C

Service C

Page 40: Cloud Native Application on DEIS by using 12 factor

Service C

Load Balancer

APIGateway

待ちによるスレッドの滞留を防ぐ

Page 41: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

共有ライブラリ

Page 42: Cloud Native Application on DEIS by using 12 factor

共有ライブラリ呪縛から解放されません?

Page 43: Cloud Native Application on DEIS by using 12 factor

顧客管理 受注管理 物流管理 売り上げ管理

商品管理 レコメンド 顧客分析 経営分析

共有ライブラリ

Page 44: Cloud Native Application on DEIS by using 12 factor

共有ライブラリ

顧客管理 受注管理 物流管理 売り上げ管理

商品管理 レコメンド 顧客分析 経営分析

共有ライブラリにバグがみつかった!!

えっ?!全部再テスト?

追加機能に影響が!!

リリース・スケジュール延期!!

Page 45: Cloud Native Application on DEIS by using 12 factor

顧客管理

受注管理

商品管理

レコメンド

共有ライブラリ

ライブラリ

顧客管理

ライブラリ

商品管理

ライブラリ

受注管理

ライブラリ

レコメンド

Page 46: Cloud Native Application on DEIS by using 12 factor

バグがみつかった!!

v1

顧客管理

v1

受注管理

v2

顧客管理

Page 47: Cloud Native Application on DEIS by using 12 factor

ビルド

Page 48: Cloud Native Application on DEIS by using 12 factor

プライベートレポジトリ建てましょう

Page 49: Cloud Native Application on DEIS by using 12 factor

https://youtu.be/Wj4yQpDxe_k

Page 50: Cloud Native Application on DEIS by using 12 factor

ライブラリ v1

商品管理

ライブラリ v2

レコメンド

ライブラリ v1

物流管理

ライブラリ v2

売り上げ管理

共有ライブラリ依存から脱却しましょう

Page 51: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

リソース設定を柔軟に !!

Page 52: Cloud Native Application on DEIS by using 12 factor

どこでも動くアプリを心掛けましょう

Page 53: Cloud Native Application on DEIS by using 12 factor

外部リソースの設定

サービス

JDBC メッセージ

プログラム?XML?

Page 54: Cloud Native Application on DEIS by using 12 factor
Page 55: Cloud Native Application on DEIS by using 12 factor
Page 56: Cloud Native Application on DEIS by using 12 factor

https://youtu.be/LVo_6AdC4wQ

Page 57: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

ビルドリリース実行

Page 58: Cloud Native Application on DEIS by using 12 factor

Build Release Run

$ mvn clean package

$ docker build .

$ mvn deploy

$ docker push

$ java –jar App.jar

$ docker run

Page 59: Cloud Native Application on DEIS by using 12 factor
Page 60: Cloud Native Application on DEIS by using 12 factor

https://youtu.be/e7hIwW9c4Es

Page 61: Cloud Native Application on DEIS by using 12 factor
Page 62: Cloud Native Application on DEIS by using 12 factor

https://youtu.be/N52zkq4hsFg

Page 63: Cloud Native Application on DEIS by using 12 factor

$ deis releases -a lonely-jokester=== lonely-jokester Releases

v6 2017-04-26T14:41:41Z yoterada added DATABASE_URL

v5 2017-04-26T14:27:08Z yoterada rolled back to v2

v4 2017-04-26T14:09:56Z yoterada changed healthcheck

info for proc type cmd

v3 2017-04-26T14:09:03Z yoterada added healthcheck

info for proc type cmd

v2 2017-04-26T12:29:44Z yoterada deployed 545623c

v1 2017-04-26T12:26:01Z yoterada created initial

release

Page 64: Cloud Native Application on DEIS by using 12 factor

$ deis rollback v2 -a lonely-jokester

Rolling back to v2... done, v5

$ deis releases -a lonely-jokester

=== lonely-jokester Releasesv5

2017-04-26T14:27:08Z yoterada rolled back to v2

V4 2017-04-26T14:09:56Z yoterada changed healthcheck

info for proc type cmd

V3 2017-04-26T14:09:03Z yoterada added healthcheck

info for proc type cmd

V2 2017-04-26T12:29:44Z yoterada deployed 545623c

V1 2017-04-26T12:26:01Z yoterada created initial

release

Page 65: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

廃棄容易性

Page 66: Cloud Native Application on DEIS by using 12 factor

起動時間の最小化

不意な停止に対応

素早い起動・停止

Page 67: Cloud Native Application on DEIS by using 12 factor

https://youtu.be/oXk4-LkQOfA

Page 68: Cloud Native Application on DEIS by using 12 factor

$ deis autoscale:set cmd

--min=3 --max=8 --cpu-percent=75 -a

lonely-jokesterApplying

autoscale settings for process type cmd

on lonely-jokester... Done

$ deis autoscale:list -a lonely-jokester

=== lonely-jokester Autoscale

--- cmd:

Min Replicas: 3 Max Replicas: 8 CPU: 75%

Page 69: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

自己完結型アプリケーション

Page 70: Cloud Native Application on DEIS by using 12 factor

自己完結で軽量に動くアプリにポートバインディングを通してサービスを公開

Page 71: Cloud Native Application on DEIS by using 12 factor

https://youtu.be/ag4edz5ff-Q

Page 72: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

開発・本番一致

Page 73: Cloud Native Application on DEIS by using 12 factor

開発と本番環境の環境は統一しましょう

開発環境 テスト環境 本番環境

Java JDK 8 u121 JDK 8 u72 JDK 8 u20

Ruby 2.3.0 2.2.4 2.2.4

MySQL 5.6 5.5 5.5

OS Win/Ubuntu RedHat RedHat

Page 74: Cloud Native Application on DEIS by using 12 factor

開発と本番環境の環境は統一しましょう

開発環境 テスト環境 本番環境

Java JDK 8 u121 JDK 8 u121 JDK 8 u121

Ruby 2.4.1 2.4.1 2.4.1

MySQL 5.7 5.7 5.7

OS Ubuntu Ubuntu Ubuntu

Page 75: Cloud Native Application on DEIS by using 12 factor

ホット・デプロイから継続的デプロイ

すべての変更を自動的に本番での検証

• Feature Flag

• Blue/Green Deploy

• A/B Test

• Canary Test

• Red/Black

Page 76: Cloud Native Application on DEIS by using 12 factor

Feature Flag

Page 77: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

運用・監視ログ

Page 78: Cloud Native Application on DEIS by using 12 factor
Page 79: Cloud Native Application on DEIS by using 12 factor
Page 80: Cloud Native Application on DEIS by using 12 factor
Page 81: Cloud Native Application on DEIS by using 12 factor
Page 82: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

さいごに

Page 83: Cloud Native Application on DEIS by using 12 factor

おきないように頑張る ?

起きても大丈夫なように作る?

障害はおきる!!

Page 84: Cloud Native Application on DEIS by using 12 factor

分散コンピューティングの落とし穴

Page 85: Cloud Native Application on DEIS by using 12 factor

誤った考えかた

https://blogs.oracle.com/jag/resource/Fallacies.html

Page 86: Cloud Native Application on DEIS by using 12 factor

分散コンピューティングを意識したシステム開発

Page 87: Cloud Native Application on DEIS by using 12 factor

どこで障害が発生する?仮想 IP

LB

App Server

ハートビート

HA-Cluster

ハートビート

仮想 IP

Page 88: Cloud Native Application on DEIS by using 12 factor

今だから再び !!オススメの一冊

Page 89: Cloud Native Application on DEIS by using 12 factor

マイクロ・サービス

Face API

Emotion API

Bot Framework

Azure Managed MySQL

VSTS

DEIS

Kubernetes

Azure Container Services

12 Factor App

Git Maven

Nexus 3

Payara Micro

Docker

Java

Page 90: Cloud Native Application on DEIS by using 12 factor

https://aka.ms/deis-k8s-acs

Page 91: Cloud Native Application on DEIS by using 12 factor
Page 92: Cloud Native Application on DEIS by using 12 factor

Microsoft OSS

Page 93: Cloud Native Application on DEIS by using 12 factor

セッションアンケートにご協力ください

専用アプリからご回答いただけます。

decode 2017

スケジュールビルダーで受講セッションを登録後、アンケート画面からご回答ください。

アンケートの回答時間はたったの 15 秒です!

Page 94: Cloud Native Application on DEIS by using 12 factor

Ask the Speaker のご案内

本セッションの詳細は『Ask the Speaker Room』各コーナーカウンタにて

ご説明させていただきます。是非、お立ち寄りください。

Page 95: Cloud Native Application on DEIS by using 12 factor
Page 96: Cloud Native Application on DEIS by using 12 factor

© 2017 Microsoft Corporation. All rights reserved.

本情報の内容(添付文書、リンク先などを含む)は、作成日時点でのものであり、予告なく変更される場合があります。

Page 97: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

データベース連携

Page 98: Cloud Native Application on DEIS by using 12 factor

顧客管理 受注管理 物流管理 売り上げ管理

商品管理 レコメンド 顧客分析 経営分析

企業システム DB

Page 99: Cloud Native Application on DEIS by using 12 factor

顧客管理サービス

顧客管理 DB

受注管理サービス

受注管理 DB

物流管理サービス

物流管理 DB

売上管理サービス

売上管理 DB

JDBC 接続プール

JDBC 接続プール

JDBC 接続プール

JDBC 接続プール

Page 100: Cloud Native Application on DEIS by using 12 factor

受注管理サービス

顧客管理 DB

物流管理サービス

物流管理 DB

JDBC 接続プール

JDBC 接続プール

Page 101: Cloud Native Application on DEIS by using 12 factor

顧客管理 DB 物流管理 DB

受注管理サービス

物流管理サービス

JDBC 接続プール

JDBC 接続プール

受注完了

メッセージング・システム

メッセージ連携

受注発生

Page 102: Cloud Native Application on DEIS by using 12 factor

イベント処理

Page 103: Cloud Native Application on DEIS by using 12 factor

はじめに

Java SE の現在と将来

Java EE の現在と将来

その他

Page 104: Cloud Native Application on DEIS by using 12 factor
Page 105: Cloud Native Application on DEIS by using 12 factor

メッセージ駆動 (Message Driven)Consumer-Driven Contracts

Page 106: Cloud Native Application on DEIS by using 12 factor

https://github.com/DiUS/pact-jvm