日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

SpringCloudGateway实现金丝雀发布_05

發布時間:2024/9/27 javascript 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SpringCloudGateway实现金丝雀发布_05 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

接上一篇:SpringCloudGateway 集成 nacos 整合實現動態路由

文章目錄

          • 一、啟動服務
            • 1. 啟動Gateway-Serv模塊服務
            • 2. 啟動auth-serv認證授權服務
            • 3. 啟動product-serv服務
            • 4. 啟動product-serv服務2
          • 二、修改nacos配置
            • 2.1. 配置改造
            • 2.2. 配置發布
          • 三、測試驗證
            • 3.1. 訪問產品模塊
            • 3.2. 獲取toeken
            • 3.3. 攜帶toekn訪問產品模塊
            • 3.4. 增加訪問次數
          • 四、不聯網大廠產品發布策略
            • 4.1. 藍綠發布
            • 4.2. 金絲雀發布
            • 4.3. 灰度發布
            • 4.4. A/B測試
            • 4.5. 測試發布策略區別

一、啟動服務
1. 啟動Gateway-Serv模塊服務

2. 啟動auth-serv認證授權服務

3. 啟動product-serv服務

4. 啟動product-serv服務2

端口由9000改為9001

server:port: 9001 spring:cloud:nacos:discovery:service: product-servserver-addr: localhost:8848

controller訪問改造
將IPhone 12改為我是新版本

package com.gblfy.controller;import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController;@RestController public class ProductController {//http://localhost:9000/product/" + productId@GetMapping("/product/{productId}")public String getProductName(@PathVariable Integer productId) {return "IPhone 12";} } package com.gblfy.controller;import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController;@RestController public class ProductController {//http://localhost:9000/product/" + productId@GetMapping("/product/{productId}")public String getProductName(@PathVariable Integer productId) {return "我是新版本";} }

開啟一個應用以不同端口啟動

啟動product-serv服務9001

二、修改nacos配置
2.1. 配置改造

spring:cloud:gateway:routes:- id: producturi: lb://product-servpredicates:- Host=product.gblfy.com**- id: authuri: lb://auth-servpredicates:- Path=/oauth/token- id: skilluri: http://localhost:13000predicates:- Path=/skilldatasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/auth-serv?characterEncoding=UTF-8&serverTimezone=GMT%2B8username: rootpassword: 123456

現配置

spring:cloud:gateway:routes:- id: product_v1uri: lb://localhost:9000/predicates:- Path=/product/*- Weight=service1, 95- id: product_v2uri: lb://localhost:9001/predicates:- Path=/product/*- Weight=service1, 5- id: authuri: lb://auth-servpredicates:- Path=/oauth/tokendatasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/auth-serv?characterEncoding=UTF-8&serverTimezone=GMT%2B8username: rootpassword: 123456
2.2. 配置發布

三、測試驗證
3.1. 訪問產品模塊

不請求auth-serv模塊獲取otken,直接通過網關訪問產品模塊


從上圖可以看出訪問需要認證授權

3.2. 獲取toeken

http://localhost:8081/oauth/token
通過認證授權中心獲取toekn

grant_type:password client_id:app client_secret:app username:ziya password:111111

3.3. 攜帶toekn訪問產品模塊

攜帶toekn通過網關服務訪問產品模塊
http://product.gblfy.com:8081/product/1

從圖中可以看出,獲取token后,通過網關服務可以正常請求產品模塊,并有響應報文。

3.4. 增加訪問次數

會發現95%的請求會請求老版本,5%請求會請求新的版本!

四、不聯網大廠產品發布策略
4.1. 藍綠發布

4.2. 金絲雀發布


從圖中可以看到,將發布區域的一小部分區域定義為金絲雀區域,通過線上運行服務(少量節點)中加入少量新版本的服務,也就是我們所說的金絲雀這塊區域,然后從少量的版本中,快速的得到一個反饋,我們將部分的流量導入到小部分的金絲雀區域版本當中,來快速得到反饋,嘗試我們這次上線的內容究竟有沒有問題,效果好不好,根據反饋再決定,剩余的節點是否要遷移到新的版本。

4.3. 灰度發布

通過切換線上并存版本之間路由的權重,逐步從一個版本切換為另一個版本的過程。

所有的用戶發起請求通過路由到以前的版本,新的版本沒有流量進來。
將95%的流量訪問舊的版本上,將5%的流量訪問新的版本上,來驗證新的版本是否有大量報錯,因為我的新版本上線之后,如果存在bug,只影響5%的用戶的體驗,大部分用戶不會受到影響,這樣是一個比較穩妥的實驗室做法。

當我驗證新版本后沒問題后,將100%的流流量全部切換到新版本當中。將舊版本廢棄掉。


金絲雀發布更傾向于一個快速反饋的一個流程,而灰度發布更傾向于從一個版本切換到另一個版本的平穩切換的一個目的。

4.4. A/B測試

4.5. 測試發布策略區別

待完善

總結

以上是生活随笔為你收集整理的SpringCloudGateway实现金丝雀发布_05的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。