Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microsoft Azure Web App 搭配 Storage Blob 與 Microsoft Azure SQL Database 移轉與設計概要 李匡正 (tomlee@microsoft.com) Technical Evangelist – Azure 開發工具暨平台推廣處 台灣微軟.

Similar presentations


Presentation on theme: "Microsoft Azure Web App 搭配 Storage Blob 與 Microsoft Azure SQL Database 移轉與設計概要 李匡正 (tomlee@microsoft.com) Technical Evangelist – Azure 開發工具暨平台推廣處 台灣微軟."— Presentation transcript:

1 Microsoft Azure Web App 搭配 Storage Blob 與 Microsoft Azure SQL Database 移轉與設計概要
李匡正 Technical Evangelist – Azure 開發工具暨平台推廣處 台灣微軟

2 移轉至 Azure Storage BLOB

3 Azure Storage BLOB BLOB 是儲存二進制非結構化巨量資料的機制,適合儲存影片,音樂,圖片類型資料,擁有最佳之讀取效率
BLOB 是儲存二進制非結構化巨量資料的機制,適合儲存影片,音樂,圖片類型資料,擁有最佳之讀取效率 高度延展,即時多份資料複寫 可以透過 HTTP RESTful API 方式存取支援多種程式語言 提供存取控制功能 Account Container Blob PIC01.JPG Images Contoso PIC02.JPG Video VID1.MPG

4 Azure Storage BLOB 相關資訊
TechEd 2012 9/11/2017 5:44 PM Azure Storage BLOB 相關資訊 單一 Storage Account 容量上限 500 TB 單一 Block BLOB 檔案大小上限 195 GB 單一 Page BLOB 檔案大小上限 1 TB 單一 BLOB 檔案能夠承載 60 MB Per second Throughput 與 500 requests per second (IOPS) Azure Storage BLOB 相關工具整理 AzCopy Azure Storage PowerShell © 2012 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.

5 運作方式 副本總數 使用原因 可用性 SLA 本機備援儲存體 (LRS) 區域備援儲存體 (ZRS) 異地備援儲存體 (GRS)
讀取權限異地備援儲存體 (RA-GRS) 運作方式 在單一資料中心中建立數個資料同步副本 在區域內或跨區的多個資料中心儲存二個資料副本。僅限 Block BLOB。 如同 LRS,可以在數百英哩以外的次要資料中心增加數個非同步副本 如同 GRS,在次要資料中心增加讀取權限 副本總數 3 6 使用原因 以最經濟方式使用 BLOB 儲存體 打造經濟且更可靠之 Block BLOB 儲存體 為了保護主要資料中心免於當機或損毀 在當機時提供資料讀取權限,以期能使用最多資料並確保耐用性 可用性 SLA 讀取/寫入 99.9% 寫入 99.9% 讀取 99.99%

6 存取控制機制 : Shared Access Signatures (SAS)
9/11/2017 存取控制機制 : Shared Access Signatures (SAS) 共用存取簽章 (SAS) 以 URI 上以透過編碼之簽章與相關參數控制存取權限,包含數項內容 版本號碼 (sv) 儲存體資源 (sr) 開始可以存取時間 (st) 到期時間 (se) 存取權限 (sp) 數位簽章 (sig) © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

7 Azure Storage BLOB 存取控制兩種架構
上傳/下載資料 讀取/寫入資料 Front End Proxy Service Azure Storage BLOB 身分驗證並取得 SAS 確認資源與產生 SAS SAS Provider Service 讀取/寫入資料 Azure Storage BLOB

8 移轉至 Azure SQL Database

9 相關學習資源 Azure SQL Database 技術文件 將 SQL Server 資料庫移轉至 Azure SQL Database
將 SQL Server 資料庫移轉至 Azure SQL Database Azure SQL Database 與 Microsoft SQL Server (V12) 差異 將 MySQL 移轉到 Azure SQL Database 輔助工具 Azure Blog - Data

10 Azure SQL Database 災難備援

11 Azure SQL Database 內建高可用性設計
運作機制 : 隨時保持兩個節點副本 自動同步資料 自動保持資料一致姓 自動偵測節點故障 自動錯誤回復 99.99% 不停機服務水準 單一對外邏輯資料庫 Single Logical Database DB P S Write Ack Read Value P S P S S 所有讀取皆至主要節點 (P) 所有寫入會由主要節點複寫到次要節點 (S)

12 Azure SQL Database 災難備援機制
RTO ( Recovery Time Objective ) : 系統要在多少時間內回復正常 RPO ( Recovery Point Objective ) : 可忍受的資料遺失的時間長度 業務連續性與災害復原 ( BCDR, Business Continuity and Disaster Recovery ) 相關功能 Basic 版 Standard 版 Premium 版 即時還原 ( Point in Time Restore ) 還原至過去 7 天 內的某時間點 還原過去 14 天內 的某時間點 還原過去 35 天內 地理還原 ( Geo-Restore ) RTO<24小時 RPO<24小時 標準異地資料複製備援 ( Standard Geo-Replication ) 不支援 RTO<2小時 RPO<30分鐘 主動式異地資料複製備援 ( Active Geo-Replication ) RTO<1小時 RPO<5分鐘

13 即時還原功能 Point In Time Restore
9/11/2017 即時還原功能 Point In Time Restore RA-GRS sabcp01bl21 Azure SQL Database 備份機制 每周完整備份,每日差異備份,每五分鐘做Transaction log 備份 每周與每日之備份透過 Azure Storage BLOB 地理備援功能複寫至配對之資料中心 即時還原功能 以 REST API, PowerShell 或入口管理網站進行 會建立一個新的資料庫至同一邏輯伺服器 允許還原之時間點 Basic 版 - 7 天內 Standard 版 - 14 天內 Premium 版 - 35 天內 sabcp02bl21 sabcp03bl21 寫入備份至 Azure Storage LS XYZ DB Backups DB1 Backups 會建立一個新的資料庫至同一邏輯伺服器 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

14 可自行還原資料至任何 Azure SQL Database
地理還原功能 Geo-restore RA-GRS RA-GRS sabcp01bl21 US West Storage geo-replication sabcp02bl21 sabcp01bl21 sabcp03bl21 sabcp02bl21 sabcp03bl21 可自行還原資料至任何 Azure SQL Database LS ABC LS XYZ 每日自動差異備份 DB DB 美國西部 美國東部 利用 Azure Storage 內的每日差異備份內容,在配對之資料中心內還原資料 無額外費用 RTO <24 小時, RPO <24 小時 資料還原後,資料庫連線字串會改變

15 標準異地資料複製備援 Standard geo-replication
LS OPQ DB 美國西部備援次要中心平時無法使用,一旦美國東部主要資料中心中止備援關係,美國西部即轉換為可用之主要資料庫 LS ABC LS XYZ Geo-replication DB 美國北部 DB 美國西部 美國東部 RTO <2 小時, RPO <30 分鐘 以 REST API , PowerShell API 與入口管理網站進行 自動複寫資料,但備援資料庫平時無法使用 複寫之備援資料庫必須與主要資料庫相同規格,並且必須使用指定配對之資料中心

16 主動式異地資料複製備援 Active Geo-replication
美國北部 LS DFE Geo-replication DB1 美國西部備援次要中心之資料平時可唯讀,一旦美國東部中止備援關係,美國西部即轉變為可讀可寫之主要資料庫 Geo-replication Geo-replication LS XYZ LS OPQ Geo-replication DB1.old DB1 DB1 LS ABC DB1 美國西部 美國東部 RTO < 1 小時, RPO < 5 分鐘 以 REST API , PowerShell API 與入口管理網站進行 自動複寫資料,備援之次要資料可平時可唯讀 至多複寫四份至任何資料中心 美國南部

17 Azure SQL Database 效能等級之選擇與調校

18 Database Throughput Unit – DTU
9/11/2017 Database Throughput Unit – DTU Compute Writes Reads Memory DB workload Bounding Box 最小定界框 效能儀錶板監控 相對目前選用之效能等級 DTU 上限所耗用 % Utilization 75% Read 50% Write CPU 60% Memory DTU 代表 Azure SQL Database 運算與處理能量 是混和 CPU, 記憶體, 讀取, 寫入之綜合指標 效能儀錶板上以目前選用之效能等級上限相對已經使用比率以 % 呈現 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

19 了解 Azure SQL Database 與對應規格 https://msdn. microsoft
Database Throughput Units (DTUs) 單一資料庫容量上限 (GB) 最大同時登入數量 (Max Concurrent Logins) Sessions 數上限 評測交易處理速率(Benchmark Transaction Rate) Basic 5 2 30 300 每小時處理16,600 交易 Standard/S0 10 250 60 600 每分鐘處理 521 交易 Standard/S1 20 90 900 每分鐘處理 934 交易 Standard/S2 50 120 1,200 每分鐘處理 2,570 交易 Standard/S3 100 200 2400 每分鐘處理 5,100 交易 Premium/P1 125 500 2,400 每秒鐘處理 105 交易 Premium/P2 400 4,800 每秒鐘處理 228 交易 Premium/P4 800 9,600 每秒鐘處理 447 交易 Premium/P6 (舊名 P3) 1000 1,600 16,000 每秒鐘處理 735 交易

20 Azure SQL Database 之資源管理
CPU Writes Reads P1 Governor CPU Writes Reads Governor CPU Writes Reads Governor SELECT * FROM a JOIN b ON … 處理 所有的 SQL 語法都會請求使用資料庫資源,資源請求 (resource requests) 不會被拒絕 但會被占存於佇列 (queue) 內等待處理 超量的資源請求會造成 SQL 語法執行時間拉長,甚至造成執行超時 (timeouts) 錯誤

21 Azure SQL Database 資源監控
9/11/2017 Azure SQL Database 資源監控 master.sys.resource_stats 依據 5 分鐘平均 userdb.sys.dm_db_resource_stats 依據 15 秒平均 DTU 百分比是相對用戶選擇之效能等級之 DTU 上限 透過 Azure 入口管理網站可以觀察並設定警示 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

22 找出過去四小時 DTU 耗用之原因 (V12 版本適用)
SELECT AVG(avg_cpu_percent) AS 'Average CPU Utilization In Percent', MAX(avg_cpu_percent) AS 'Maximum CPU Utilization In Percent', AVG(avg_data_io_percent) AS 'Average Data IO In Percent', MAX(avg_data_io_percent) AS 'Maximum Data IO In Percent', AVG(avg_log_write_percent) AS 'Average Log Write Utilization In Percent', MAX(avg_log_write_percent) AS 'Maximum Log Write Utilization In Percent' FROM sys.resource_stats WHERE database_name = ‘<您的資料庫名稱>' AND start_time > DATEADD(hour, -4, GETDATE())

23 找出最耗資源之十大 SQL 語法 SELECT TOP 10 SUBSTRING(qt.TEXT, (qs.statement_start_offset/2)+1, ((CASE qs.statement_end_offset WHEN -1 THEN DATALENGTH(qt.TEXT) ELSE qs.statement_end_offset END - qs.statement_start_offset)/2)+1), qs.execution_count, qs.total_logical_reads, qs.last_logical_reads, qs.total_logical_writes, qs.last_logical_writes, qs.total_worker_time, qs.last_worker_time, qs.total_elapsed_time/ total_elapsed_time_in_S, qs.last_elapsed_time/ last_elapsed_time_in_S, qs.last_execution_time, qp.query_plan FROM sys.dm_exec_query_stats qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qt CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp ORDER BY qs.total_logical_reads DESC

24 了解 SQL 語法耗用大量資源之原因 SET STATISTICS IO ON SET STATISTICS TIME ON
9/11/2017 了解 SQL 語法耗用大量資源之原因 SET STATISTICS IO ON SET STATISTICS TIME ON 執行最耗資源之 SQL 語法 了解耗用資源之原因 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

25 Azure SQL Database Elastic Database 彈性資料庫

26 我擁有八十萬用戶,每秒需要存取資料庫超過一萬次,Azure SQL Database 該如何處理?

27 Azure SQL Database 向外水平延展方案
正式服務 Multi-database management Keep track of the databases in your data tier Map customers (tenants) to databases Data-dependent routing (資料相依路由) 依據用戶端請求內容繞徑至正確之資料庫 簡化資料庫 patterns - Database Sharding 實作 當資料庫搬移,合併,切割確保資料庫遶徑依然正確 將資料庫繞徑資訊快取提升效率 Elastic Database Tools Microsoft .NET 相關範例與函式庫可由 NuGet 取得

28 傳統資料模型 傳統關聯式資料線上交易 (OLTP) 模型

29 Sharding 資料模型 Sharding Key : CustID
Sharded 資料模型將資料分散在多個資料庫,每個資料庫使用相同之 Database Schema,透過 Sharding Key 關聯至各分散之資料庫 所有單一客戶資料皆存放在同一資料庫之內,傳統 OLTP 運作如常 資料庫設計時避免跨資料庫進行交易 (Transaction) 與跨資料庫 Join 資料 每個資料庫可以只存放單一客戶資料 (Single tenancy) ,也可存放多個客戶資料 (Multi tenancy) Sharding Key : CustID

30 Data-Dependent Routing (資料相依路由)
1. 用戶連接某項雲端應用服務 Cloud Service 2. 雲端應用服務依據用戶編號至扮演 Shard Map Manager 角色的用戶目錄資料庫進行查詢,以便得知該用戶資料位於哪一個資料庫內 3. 雲端應用服務繞境至真正存放該用戶之資料庫 Catalog Customer Catalog Shard Map Manager Cust 1 Cust 2 Cust 3 Cust N Customer Databases Shard

31 Data-Dependent Routing
Sharding Key : CustID // Looks up the key in the shard map and opens a connection to the shard using (SqlConnection conn = shardMap.OpenConnectionForKey(customerId, credentialsConnectionString)) { // Create a simple command that will insert or update the customer information SqlCommand cmd = conn.CreateCommand(); cmd.CommandText IF EXISTS (SELECT 1 FROM Customers WHERE CustId UPDATE Customers SET FirstName LastName WHERE CustId ELSE INSERT INTO Customers (CustId, FirstName, LastName) @lastname)"; customerId); firstName); lastName); cmd.CommandTimeout = 60; // Execute the command cmd.ExecuteNonQuery(); }

32 Elastic Database Query
跨越多個 Sharding 資料庫查詢 技術預覽階段 2015 AUG Elastic Database Query 為了配合現有各類需要與資料庫互動之 BI 或報表工具,提供使用 Elastic Database Tools 之資料庫一個單一 Azure SQL Database 連線字串 (connection strings) 將必須由多個資料庫個別查詢的動作改為從單一 資料庫內查詢 可以搭配開發人員已經熟知之 Transact-SQL, ADO. NET, LINQ , Entity Framework 等 針對報表 BI 等需要互動式查詢所設計

33 跨越多個 Sharding 資料庫查詢 PowerBI Cloud Service Customer Catalog
Elastic Query Cust 1 Cust 2 Cust 3 Cust N Customer Databases

34 管理眾多 Sharding 資料庫 Elastic Database Jobs 技術預覽階段 2015 AUG
技術預覽階段 2015 AUG Elastic Database Jobs 協助資料庫管理員將資料庫相關管理動作逐一套用至多個資料庫 資料庫管理員可用熟悉的 Transact-SQL 語法定義工作 (job) 內容 遇到工作執行失敗時內建重新嘗試機制 完全整合至新 Azure 入口管理網站 針對批次資料庫管理所設計

35 管理眾多 Sharding 資料庫 T-SQL Cloud Service Customer Catalog
Cust N Customer Databases

36 我有二十個資料庫,其中八個周一至週五中午 12:00 – 13:00 資料庫尖峰用量達到 S3 效能等級,而其餘時間只需要 S0 效能等級就夠了,我該如何處理 ?

37 Elastic Database Pools
多資料庫效能與價格管理機制 技術預覽階段 2015 AUG 多個資料庫共享資料庫資源池能夠降低整體成本 適合無法預期之資料庫存取尖峰情境 無須為了尖峰時間需求選用較高效能等級 無須為數量眾多之資料庫逐一選擇適當之效能等級 Elastic Database Pools

38 某 SaaS 軟體目前資料戶用量量測結果 資料庫尖峰時段用量達到 Azure SQL Database S3 等級
Performance level Price ($/month) S0 $15 S1 $30 S2 $75 S3 $150 20x S3 databases $3,000

39 Azure SQL Database Elastic Database Pool 效益

40


Download ppt "Microsoft Azure Web App 搭配 Storage Blob 與 Microsoft Azure SQL Database 移轉與設計概要 李匡正 (tomlee@microsoft.com) Technical Evangelist – Azure 開發工具暨平台推廣處 台灣微軟."

Similar presentations


Ads by Google