上一片文章咱們使用 Azure Traffic Manager 分發用戶請求,同時演示了兩種路由策略,「Performance」,「Geographic」的兩種方式,今天咱們繼續講解 Traffic Manager profile 的其餘幾種路由策略。咱們依舊先來看看咱們的架構圖,廢話很少說,開始今天的分享。html
咱們須要爲流量管理器配置文件配置中的每一個終結點分配權重。 而後,系統會根據分配給每一個終結點的權重進行用戶流量路由。 該權重是從 1 到 1,000 的整數。 分配給終結點的權重值越高,其優先級就越高。git
--------------------我是分割線--------------------github
Azure Web App 部署系列:web
Azure Portal 中 點擊 」Create a resource「,搜索框中輸入 「Traffic Manager profile」,進行搜索數據庫
點擊 「Create」瀏覽器
Name:「tm02-cnbateblogweb」服務器
Routing mehtod 選擇 「Weighted」(基於權重的路由策略)架構
Resource group 選擇 「Web_Test_TM_RG」app
點擊 「Create」負載均衡
Azure Portal 的消息框中,咱們能夠看到 基於權重的 Traffic Manager profile 建立成功,咱們點擊 「Go to resource」 跳轉到資源中
選擇 "Settings" => "Endpoints" ,點擊 「Add」,添加 "endpoint"(終結點)
Type:「Azure endpoint」
Name:」tm02_cnbateblogweb_webapp_performance「
Target resource type:「App Service」
Target resource:「CnBateBlogWeb(East Asia)」
Weight:20(我隨便寫的,你們不要在乎)
咱們能夠看到剛剛添加的終結點信息
咱們使用一樣的方法,將 CnBateBlogWeb01的 Web App也添加到當前 Traffic Manager 的終結點中.
Type:"Azure endpoint"
Name:"tm02_cnbateblogweb01_webapp_performance"
Target resource type:"App Service"
Target resource:"CnBateBlogWeb01"
Weight:"100"
點擊 「Add」
咱們能夠看到咱們剛剛添加的兩個終結點的狀態也是 ok的,接下來咱們就能夠進行測試
選擇 「Overview」,複製 DNS name 的 "url" 到瀏覽器,查看結果
終結點名稱 | 目標資源 | 權重 |
tm02_cnbateblogweb_webapp_performance | CnbateBlogWeb | 20 |
tm02_cnbateblogweb01_webapp_performance | CnbateBlogWeb01 | 100 |
咱們能夠看到當前 流量管理器配置將請求轉發到 「CnBateBlogWeb01」 的Web App 上了
終結點名稱 | 目標資源 | 權重 |
tm02_cnbateblogweb_webapp_performance | CnbateBlogWeb | 100 |
tm02_cnbateblogweb01_webapp_performance | CnbateBlogWeb01 | 20 |
咱們能夠看到當前 流量管理器配置將請求轉發到 「CnBateBlogWeb」 的Web App 上了
重複上述的步驟,建立路由策略爲 「Priority」 的 流量管理器配置文件
Name : "tm03-cnbateblogweb"
Routing method:「Priority」
點擊 「Create」
下圖是我添加的兩個終結點
CnBateBlogWeb 的優先級是 1
CnBateBlogWeb01 的優先級是 2
選擇 「Overview」,複製 DNS name 的 "url" 到瀏覽器,查看結果。
終結點名稱 | 目標資源 | 優先級 |
tm02_cnbateblogweb_webapp_performance | CnbateBlogWeb | 1 |
tm02_cnbateblogweb01_webapp_performance | CnbateBlogWeb01 | 2 |
咱們把 CnBateBlogWeb 的Web App 中止掉,再次進行測試
咱們能夠看到主終結點位於頂部, 全部請求均會路由到第一個終結點;若是流量管理器檢測到其處於不正常狀態,則流量會自動故障轉移到下一終結點。Priority(基於優先級的路由策略) 可按照優先級設置多個從節點(web 服務器),當其中的某個或多個節點失效時,活着的節點中具備最高優先級者對外提供服務。這個策略主要用來提升服務的可用性。
撒花,🎉🎉🎉🎉🎉
ok,今天的分析到此結束,關於Traffic Manager profile 的 Routing method 咱們分別介紹了 「Performance(基於性能的路由策略)」,「Geographic(基於地理位置的路由策略)」,「Weighted(基於權重的路由策略)」,「Priority(優先級的路由策略)」,至於剩下的兩種策略,「MultiValue(基於多值的路由策略)」 和 「Subnet(基於子網的路由策略)」,你們能夠自行看着微軟的官方介紹,嘗試實踐一下。
下一篇,咱們介紹另一種具體流量轉發,負載均衡的服務-----Azure Load Balance,期待中........
做者:Allen
項目代碼:https://github.com/yunqian44/CnBateBlogWeb.git
版權:轉載請在文章明顯位置註明做者及出處。如發現錯誤,歡迎批評指正。