AzureでMicroservicesに触れてみる
JAZUG 福岡(ふくあず) × Fukuoka.NET 合同企画
de:code2016 振り返り勉強会
2016/06/23
自己紹介
C# / VB.NET / Python / PHP
Microsoft MVP Azure
ウイスキー、日本酒
JAZUG Fukuoka(ふくあず)
Fukuoka.NET(ふくてん)
ラブライブ! - 東條希 推し
濱本 一慶(はまもと かずのり)
@airish9 (修羅イバー)
はじめに
de:code 2016
 SNR-003 - 始めよう! ドメイン駆動設計&マイクロサービス開発~C# と
Azure Service Fabric で最高の DDD 開発を~
 [NDA]DEV-013 - まだまだ進化が止まらない! 開発者のための
Microsoft Azure 最新機能
 DBP-010 - Using Azure Data Services for Modern Data Applications
 DEV-016 - 止まらないサービスを~ マイクロサービスプラットフォーム
「Azure Service Fabric」
 ARC-009 - RDB 技術者のための NoSQL ガイド
 [NDA]CHK-010 - Azure SQL Database: Current and Future
de:code 2016
 SNR-009 - Why Red Hat ♥’s Azure
 DOO-005 - 裏 Inside Azure ~OSS視点で理解する、Azureのテクノロ
ジー&アーキテクチャー~
 DBP-016 - NoSQL in Azure ~ドキュメント指向データベース Azure
DocumentDB 徹底解説~
全てを語るには
時間が足りません
陳謝
続きはふくあずで!!
Service Fabricの道のり
Microservicesとは
Service Fabric
概要
アプリケーションモデル
プログラミングモデル
Microservices
モノリシックとマイクロサービス
モノリシック
一枚岩のシステム
全ての要素が1プロセスに詰め込ま
れている
機能単位での分割
(Web,ビジネス, データ)
スケールする場合は複数のサーバー
に配置する
システム単位の変更
モノリシックとマイクロサービス
マイクロサービス
機能を細かいサービスの組み合わ
せでシステムを作るアーキテク
チャ
“マイクロ”≠小さい
役割を担うサービスの範囲が”マイ
クロ”
James Lewis氏のBlog記事で有名
になった(記事の日本語訳)
マイクロサービスに求められるもの
自律・分離
エラスティック(伸縮自在)
レジリエンス(復元・耐久力)
レスポンシブ(低レイテンシ)
メッセージ指向
(HTTP/JSON)
オートメーション
監視
Martin Fowler氏が言うMicroservicesの特性
サービスを通じたコンポーネント化
ビジネス機能ごとにサービスを構築(コンウェイの法則)
プロジェクトではなくプロダクト
スマートなエンドポイントと土管
分散統治
分散データ管理
インフラ自動化
障害のための設計
進化的な設計
Microservicesはチーム作りが大変
コンウェイの法則
「システムを設計する組織は、その構造をそっくりまね
た構造の設計を生み出してしまう」
ビジネス機能の粒度にしてチームとする必要がある
Microservicesはチーム作りが大変
Microservicesの特性イメージ
Microservicesの導入に関する問題
根本的な複雑さを産み生産性が低下する
システムの複雑さある程度高いと効果が出る
参考 : http://martinfowler.com/bliki/MicroservicePremium.html
生産性
システムの複雑さ
マイクロサービス
モノリシック
AzureとMicroservices
Web
Apps
Mobile
Apps
API
Management
API
Apps
Logic
Apps
Notification
Hubs
Content Delivery
Network (CDN)
Media
Services
HDInsight Machine
Learning
Stream
Analytics
Data
Factory
Event
Hubs
Mobile
Engagement
Biztalk
Services
Hybrid
Connections
Service
Bus
Storage
Queues
Backup
StorSimple
Site
Recovery
Import/Export
SQL
Database
DocumentDB
Redis
Cache
Search
Tables
SQL Data
Warehouse
Azure AD
Connect Health
AD Privileged
Identity Mngt
Operational
Insights
Cloud
Services
Batch Remote App
Service
Fabric Visual Studio
Application
Insights
Azure SDK
Team Project
Active
Directory
Multi-Factor
Authentication
Automation
Portal
Key Vault
Store /
Marketplace
VM Image Gallery
& VM Depot
SECURITY &
MANAGEMENT PLATFORM SERVICES HYBRID
OPERATIONS
IaaS
Virtual Machines
VM Scale Sets
Azure Container Service
Virtual Machines
VMScale Sets
コンテナー
PaaS
IaaS
VM /
VM
Scale Sets
マイクロ
サービス
Web/
モバイル
サーバーレス
PaaS
マイクロ
サービス
Web/
モバイル
サーバーレス イベント駆動コンピューティング
フルマネージドアプリケーション
複数のサービスから構成された、
大規模で可用性の高いアプリ
フレームワーク,ランタイム,アプリケーションモデル
に重点を置いたアプリ
PaaS
マイクロ
サービス
Web/
モバイル
サーバーレス
App Service
Service Fabric
Cloud Services
Azure Functions
Service Fabric
Service Fabric
2015/04(Build 2015)
発表・開発者プレビュー
2015/11
Azure Service Fabric Preview
2016/03(Build 2016)
Azure Service Fabric GA – 西日本
Windows Server – Public Preview
Linux(Java SDK, Docker) - Preview
Service Fabricの機能
 Application deployment services:
 ローリングアップデート&ロールバック
 協力なバージョン管理
 並列実行サポート
 アプリケーションを発見するための名前付け
 パーティショニング
 負荷分散と配置制約(placement constraints)
 一貫性のある状態でのレプリケーション
 一貫性のある分散型コレクション
Service Fabric
マイクロサービス プラットフォーム
プロビジョニング
デプロイ
監視
クラスター環境
ノーロックイン
ステートフル / ステートレス
マクロサービスアプリケーションAPI
.NET / Java
Service Fabric
Microsoft社内で5年間運用されていた
Service Fabricで運用されているもの
Azure
SQLDatabase / DocumentDB / Power BI / Networking
Event Hubs / Service Bus
Intune
Bing Cortana
Skype for Businness
Service Fabricの効果
生産性
システムの複雑さ システムの複雑さ
生産性
A
B B
A
C
C
A:Microserviceにかかる生産性の低下を小さく
B:Microserviceのメリットが得られる複雑さを小さく
C:Microsericeのメリットを大きく
Service Fabric
https://azure.microsoft.com/ja-jp/documentation/articles/service-fabric-overview/
No lock-in
https://msdn.microsoft.com/en-us/magazine/mt595752.aspx
Here are some of the benefits of Service Fabric:
Runs on Azure, on-premises or in any cloud. A very important characteristic of
Service Fabric is that you can run it on Azure, but also on-premises, on your own
bare-metal servers or virtual machine (VMs), and even in other third-party hosted
clouds. There’s no lock-in to a specific cloud. You could even run a Service
Fabric cluster in Amazon Web Services (AWS).
Supports Windows or Linux. Currently (late 2015) Service Fabric supports Windows,
but it will also support Linux and containers (Windows images and Docker images).
Fully vetted. Service Fabric has been used for several years by Microsoft to power
many of its cloud products.
https://channel9.msdn.com/Events/Build/2015/3-618
Service Fabricの構成(Azure)
VM Scale SetService Fabric
Cluster
Public IP
Load Balancer
Network
VM StorageLog Storage Diagnostic
Storage
Service Fabricの構成(Azure)
LB + VM Scale Set + Cluster
Cluster
監査ログストレージアカウントの指定
管理用エンドポイント
信頼性のランク(プラチナ / ゴールド / シルバー / ブロンズ)
ノードのVM数,耐久性の選択
各ノードはVM Extensionsを利用して連携する
 https://azure.microsoft.com/ja-jp/documentation/articles/virtual-machines-windows-
extensions-features/
Cloud Serive(PaaSv1)の問題点
Azure Cloud Services
(Web Role/Worker Role)
 可用性を保つには複数Node(=インスタンス)が必要
 Roleを増やすとNodeが増える
 Nodeが増えるとリソースに無駄が生じやすい
 Static Partitioning問題というらしい
 デプロイ更新が遅い
 スケーリング / DRが遅い
複数のRoleをNodeに入れてしまえばいいのではないか?
Service FabricではNodeに複数Roleを格納する
Cloud Serive(PaaSv1)とService Fabric
Azure Cloud Services
(Web Role/Worker Role)
• 各 Node に 1つのRole
• 均一でないワークロード
• コンピューティングの密度が低い
• デプロイ/更新が遅い
• スケーリング/DR (災害復旧) が遅い
Azure Service Fabric
(ステートレス/ステートフル/アクター サービス)
• 各 Node に複数のRole
• マイクロサービスの密度が高い
• デプロイ/更新が速い
• クラスター内でのマイクロサービスの
スケーリングが速い
アプリケーションモデル
Application model
https://azure.microsoft.com/en-us/documentation/articles/service-fabric-application-model/
Application
Applicationは複数のServiceから構成される
ApplicationManifest.xmlに定義
アプリケーションが保持するServiceの情報
アプリケーションのTypeとVersion
インスタンス数など
Service
ServiceはCode,Data,Configから構成される
ServiceManifest.xmlに定義
Code(実行可能ファイル)の情報
Configの情報
Data(静的リソース)の情報
サービスのTypeとVersion
サービス用のEndpointに関する情報
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="Stateless1Pkg"
Version="1.0.0">
<ServiceTypes>
<StatelessServiceType
ServiceTypeName="Stateless1Type" />
</ServiceTypes>
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>Stateless1.exe</Program>
</ExeHost>
</EntryPoint>
</CodePackage>
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<Endpoint Name="ServiceEndpoint" />
</Endpoints>
</Resources>
</ServiceManifest>
<ContainerHost>
<ImageName>myNodeImage:latest</ImageName>
<Commands></Commands>
</ContainerHost>
プログラミングモデル
プログラミングモデル
Reliable
service
Stateless
service
Stateful
service
Reliable
actor
Guest
executable
プログラミングモデル
Guest Executables
(ゲスト実行可能ファイル)
• 任意の EXE を持ち込む
• 任意の言語/
プログラミング モデル
• アプリとしてパッケージング
• バージョニング/更新/
正常性監視などの
機能を追加
Reliable Services
(サービス)
• ステートレス/ステートフル
• 同時実行性
• Reliable Collection に
よる状態管理、
トランザクション
• 完全なプラットフォーム
Reliable Actors
(アクター)
• ステートレス/ステートフルな
アクター オブジェクト
• 簡素化された
プログラミング モデル
• 単一スレッド モデル
• コンピューティングと状態の
スケール アウトに最適
https://azure.microsoft.com/ja-jp/documentation/articles/service-fabric-choose-framework/
Stateful / Stateless
Stateful / Stateless
Reliable
service
Stateless
service
Stateful
service
Reliable
actor
Guest
executable
StatefulのPartitioning
サービスのパーティション分割可能
ルーティングはService Fabricのランタイムが行う
Nodeとデータの割り当てはService Fabricのランタイムが管理
Node 5Node 4Node 3 Node 6Node 2Node 1
P2
S
S
S
P4
S
P1
S
P3S
S
S
従来との比較
StatelessWeb
Stateless Computing cache
State Data
StatelessWeb
Stateful Computing
まとめ
Microservices
システムを細かいサービスで構成するアーキテクチャ
チーム構成もマイクロサービスを意識する必要がある
開発当初は生産性が落ちる、採用する際の見極め大事
Service Fabric
マイクロサービスプラットフォーム
LB + VM Scale Set + Cluster
Serviceの種類はStateful と Statelessで大きく2つ
しゅくだい
プログラミングモデル部分をもっと深く
Reliable Services / Reliable Actors
Service Fabricのランタイムに関する部分
続きは、ふくあず で!!
ご清聴ありがとうございました
参考
Azure Fabric Service - 第1回 Tokyo Jazug Night
https://channel9.msdn.com/Blogs/MVP-Azure/01-Tokyo-Jazug-
Night
祝GA、 Service Fabric 概要
http://www.slideshare.net/takekazuomi/ga-service-
fabric
止まらないサービスを~ マイクロサービスプラット
フォーム 「Azure Service Fabric」
https://docs.com/decode2016/1872/dev-016-azure-
service-fabric

Azureでmicroservicesに触れてみる