45
Windows Azure 應應應應應應 (Application Architecture) 應應應 ( 應應 ) Microsoft MVP of Windows Azure / MCSD: Web Applications 應應應應應應應應

Windows Azure Application Architecture

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Windows Azure Application Architecture

Windows Azure 應用程式架構 (Application Architecture)朱明中 ( 小朱 )Microsoft MVP of Windows Azure / MCSD: Web Applications台灣微軟資深講師

Page 2: Windows Azure Application Architecture

大綱• 雲端和本地是有差異的• 故障防護 (Failsafe)• 擴展性 (Scalability)• 整合度 (Integration)• 應用程式架構樣式 (Patterns)

Page 3: Windows Azure Application Architecture

雲端和本地是有差異的

Page 4: Windows Azure Application Architecture

共同的迷思• “ 這是硬體錯誤,不關我的事”• “ 我們能在我們的資料庫伺服器上使用更多的記憶體”• “ 因為使用 Azure ,我們的服務可到 99.9%”• “ 執行超出能力的工作,這真是個好問題”• “ 我可以將任何東西移到雲端”

Page 5: Windows Azure Application Architecture

為雲端而設計• 錯誤防護• 任何東西都會發生錯誤。

• 擴展• 擴展能力並不是自動的。

• 整合• 您的雲端應用會需要與其他本地系統一起工作。

Page 6: Windows Azure Application Architecture

錯誤防護

Page 7: Windows Azure Application Architecture

可用度

• 贅餘配置

𝐴𝑣𝑎𝑖𝑙𝑎𝑏𝑖𝑙𝑖𝑡𝑦=𝑢𝑝𝑡𝑖𝑚𝑒

𝑢𝑝𝑡𝑖𝑚𝑒+𝑑𝑜𝑤𝑛𝑡𝑖𝑚𝑒

= 99.9%

A (90%)

B (90%)

C (90%)

• 組合配置

A (99.9%) B (99.9%) C (99.9%)

= 99.7%

Page 8: Windows Azure Application Architecture

Windows Azure 內的贅餘配置 • Windows Azure Storage 具備複本能力。• SQL Database 內建備份伺服器• Windows Azure Caching 具有高可用能力。• 利用多執行個體的 Windows Azure Web Sites 與 Cloud

Services 。• 設定負載平衡的 Virtual Machines 。• Windows Azure Virtual Network 閘道已內建贅餘配置 。• 使用 Windows Azure Traffic Manager 達到容錯能力。

Page 9: Windows Azure Application Architecture

穩定性MTTF

MTTR

MTBF

可用

MTTR First:

MTTF First:

不可用

Page 10: Windows Azure Application Architecture

Windows Azure 的穩定性• 自動復原 已當機或未回應的執行個體。• 錯誤域 (Fault Domain) 跨機櫃配置執行個體。• 虛擬機器的可用集 (Availability set) 將虛擬機器配置於錯誤域

內。• 更新域 (Upgrade domain) 防止所有執行個體在同一時間內關

機。• VIP 交換 (swap) 允許將轉換環境提升到生產環境。• 模擬器與 Intellitrace 與強化的診斷功能。• 對 遠端監測 (telemetry) 的第一方與第三方支援。• 使用 Transient Fault Handling Application block 處理瞬間

錯誤。

Page 11: Windows Azure Application Architecture

對我的應用程式而言,什麼是錯誤防護?• 運用 Windows Azure 功能的優點。• 預防單點失敗 (single point of failure) 。• 失敗模式分析。• 瞬間錯誤。• 優雅降級。• 降低人因問題。

Page 12: Windows Azure Application Architecture

擴展

Page 13: Windows Azure Application Architecture

擴展力• 向上或向外擴展

0 1 2 3 4 5 6 7 8

執行個體

產量

執行個體能量

配額

Page 14: Windows Azure Application Architecture

容量規劃與擴展單元

Time

容量

工作負載

服務 x 個客戶,我需要 i 個運算節點, j 個工作佇列, k 個儲存帳戶,…

𝑡𝑢 ,∆𝑊 (𝑡)≤𝐶𝑢

Page 15: Windows Azure Application Architecture

Windows Azure 的擴展力• 向上擴展:處理不同的虛擬機器大小。• 向外擴展:加入更多執行個體。• 自動擴展:運用 Windows Azure 本身的功能或撰寫自已的規

則。• 資料庫抽象化 (shading) :將多個資料庫抽象為一個• 向外擴展:運用多個服務實體。• CDN :分散使用者流量。• 快取:處理伺服器的工作負載。

Page 16: Windows Azure Application Architecture

對我的應用程式而言,什麼是擴展?•容量規劃•適當的的系統分解•無狀態設計•在任何層次都能做擴展•節流

Page 17: Windows Azure Application Architecture

擴展的不同等級無狀態 共享狀態 全域狀態

R

R

R

R

R

R

R

R

R

R

S

S

R

R

R

R

R

S

R

R

R

R

R

R

R

R

R

R

R

R

R

SR

RS

R

R

R

R

R

S

R

R

R

R

R

S

Router

移除全域狀態分離狀態與動作

Page 18: Windows Azure Application Architecture

分離動作與狀態• 外部化狀態 ( 將狀態移到分散式快取區 )• Cache session state provider

(Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache)

• 分離動作與狀態• Job creator• Job queue• Job Handler

Job Creator

Job Handler

Job Queue

Job Handler

Page 19: Windows Azure Application Architecture

與本地系統整合

Page 20: Windows Azure Application Architecture

移轉到雲端的決策圖雲端是否

真有幫助 ?定義 / 精煉目標 建立底線

估計收益

相依分析

商業影響分析

值得做嗎 ?

同意 ?

相依嗎 ?

開始

影響分析

同意 ?

整合策略

Page 21: Windows Azure Application Architecture

一般性的整合策略• 與資料整合• 直接互動• 中間層

Page 22: Windows Azure Application Architecture

Windows Azure 內的整合• 訊息通訊為主的整合:使用 Windows Azure 服務匯流排• 連線能力:使用 Windows Azure Virtual Network• 整合您的 本地 AD :使用 Windows Azure Active Directory• 單一簽入:使用 Windows Azure 存取控制服務• 包容性生態系統:支援異質性環境• 擁抱 標準 如 HTTP, Oauth, oData, ws-*

Page 23: Windows Azure Application Architecture

對我的應用程式而言,什麼是整合?•鬆散耦合•讓暴露在外的服務或資料最小化•整合隔離•預設就是安全的•使用標準

Page 24: Windows Azure Application Architecture

與本地系統整合• 訊息為主的整合

System A System B

Queue

System C

TopicSystem D

System E

System FSystem G

System H

Page 25: Windows Azure Application Architecture

與本地系統整合• 虛擬網路

LAN VNet

Site-to-Site

Point-to-Site

Page 26: Windows Azure Application Architecture

Windows Azure Active Directory• 提供應用程式的存取控制能力。• 應用程式內的單一簽入。• 跨企業的社群連線。• 整合您的本地 AD 。

1

WAADTenant

ApplicationWIF

AppLogin Page

2

3

4

AD

ApplicationWIF

App

Page 27: Windows Azure Application Architecture

雲端應用程式架構

Page 28: Windows Azure Application Architecture

WIF ASP.NET

MVC 3

Web RoleCustom STS

Access Control

Web SiteUser Web Application

ASP.NET MVC 4

Web SiteBack office Web Application

ASP.NET MVC 4

Virtual MachineFed Net Protocol

Socket Server

Web SiteNative Protocol

ASP.NET Web API

Ationet Gateway

SQL Database

DBAzure Tables

Vending Machines

PoS

Dispenser controller.NET Micro

framework

ATIONet

Page 29: Windows Azure Application Architecture

雲端應用程式架構樣式• 基本應用程式架構樣式 (Basic Application

Architecture Pattern)• 彈性樣式 (Elasticity Pattern)• 可用度樣式 (Availability Pattern)• 多租戶樣式 (Multi-tenancy Pattern)

Page 30: Windows Azure Application Architecture

基本應用程式架構樣式組合式應用程式(Composite Application)

將應用程式的功能切分,各個部份以一個組合語言 (composition language) 來整合,讓它合成為一個獨立的應用程式。

Page 31: Windows Azure Application Architecture

基本應用程式架構樣式鬆散耦合(Loosely-Coupled)

將元件之間的直接通訊去除,以一個中間通訊的方式來提供,並且讓元件可以自主運作。

Page 32: Windows Azure Application Architecture

基本應用程式架構樣式無狀態元件(State-less Component)

將元件的內部狀態 (internal

state) 去除,移到外部的狀態儲存地,以支援擴展情境。

Page 33: Windows Azure Application Architecture

基本應用程式架構樣式鑒一性元件(Idempotent Component)

實作元件對於訊息的處理必須保持鑒一性 ( 一定只處理一次 ) ,以保護應用程式不會重覆處理相同的訊息。

Page 34: Windows Azure Application Architecture

彈性樣式分解 -歸納模式(Map-Reduce)

將資料打散給一定數量的資料處理服務各自處理後,將結果組合起來成為最終結果。

Page 35: Windows Azure Application Architecture

彈性樣式彈性化元件(Elasticity Component)

由系統自動偵測服務的負載,並自動處理擴展的模式與類型。

Page 36: Windows Azure Application Architecture

彈性樣式彈性化負載平衡(Elasticity Load Balancing)

由系統自動偵測應用程式的流量,並將流量分配給負載較輕的處理器。而負載平衡的工作由系統自動調配。

Page 37: Windows Azure Application Architecture

彈性樣式彈性化佇列(Elasticity Queue)

由系統偵測目前佇列以及服務負載的情況,自動將佇列內的要求分派給負載較輕的服務處理,並且可自動處理擴展的情境。

Page 38: Windows Azure Application Architecture

可用性樣式看門狗(Watchdog)

在系統中佈建數個監控服務或網站健康狀態的運算節點,以偵測並回報系統內服務或網站的健康狀態,以支援自動復原的機制。

Page 39: Windows Azure Application Architecture

可用性樣式更新遞移(Updating Transition)

由系統監控軟體更新的過程,並且自動更新目前服務對外的連線,以支援軟體的版本更新,且又不會讓服務中斷。

Page 40: Windows Azure Application Architecture

多租戶樣式單一執行個體元件(Single Instance Component)

部署單一元件,並設計共享機制讓所有租戶能共享此元件的功能。

Page 41: Windows Azure Application Architecture

多租戶樣式單一可組態執行個體元件(Single Configurable Instance Component)

部署單一元件,但針對個別租戶設計組態隔離機制,讓個別使用者能依各自的組態於單一元件上執行。

Page 42: Windows Azure Application Architecture

多租戶樣式多執行個體元件(Multiple Instances Component)

為個別租戶部署元件,並以各自的組態來設定並執行元件。

Page 43: Windows Azure Application Architecture

總結1. 雲端不是本地環境,請用雲端思維來分析與設計應用程式。2. Windows Azure 有許多資源可協助開發分散式應用程式。3. 擴展力,整合力與錯誤防護力是雲端應用的基本特性。4. 運用 Pattern 協助您規劃與發展雲端應用。

Page 44: Windows Azure Application Architecture

參考資源Windows Azure Application Architectures: http://www.windowsazure.com/en-us/develop/net/architecture/Cloud Application Architecture Patterns: http://cloudcomputingpatterns.org

Page 45: Windows Azure Application Architecture

© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to

be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.