通过gateway实现服务的平滑迁移

本文属于b站图灵课堂springcloud笔记系列。讲得好还不要钱,值得推荐。

配置下试试。

再之前库存工程,新增了一个测试类

java 复制代码
package org.tuling.tlmallstorage.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.atomic.AtomicInteger;

@RestController
public class UrlController {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Value("${abcd.url:dddd}")
    private String url;

    private static final AtomicInteger URL_COUNT = new AtomicInteger(0);
    private static final AtomicInteger NEW_URL_COUNT = new AtomicInteger(0);

    @GetMapping("/url")
    public String url(){
        int count = URL_COUNT.incrementAndGet();
        logger.info("url count:{}",count);
        return url;
    }

    @GetMapping("/new/url")
    public String newUrl(){
        int count = NEW_URL_COUNT.incrementAndGet();
        logger.info("new_url count:{}",count);
        return url;
    }
}

gateway 修改下application.yml

启动postman跑几百次,postman 得先把url save到collection,再从collection run ,设置迭代次数,这个不如jmeter方便。

观看下结果,大致符合设置权重:5:1.

官网的例子更直接:可以指定了机器。这样就是在nacos动态配置,开始老的机器占比达,慢慢调整到新机器上,实现平滑迁移。

相关推荐
Dontla1 天前
Kubernetes流量管理双雄:Ingress与Gateway API解析(Nginx与Ingress与Gateway API的关系)
nginx·kubernetes·gateway
JavaLearnerZGQ1 天前
Gateway网关将登录用户信息传递给下游微服务(完整实现方案)
微服务·架构·gateway
Ares-Wang2 天前
网络》》BGP Border Gateway Protocol,边界网关协议
网络·gateway
一方_self3 天前
cloudflare AI gateway实战代理任意第三方大模型服务提供商
人工智能·gateway
雨中飘荡的记忆5 天前
Spring AI Gateway:从入门到实战,打造智能AI服务网关
人工智能·spring·gateway
没有bug.的程序员6 天前
Spring Cloud Gateway:API网关限流与熔断实战
java·开发语言·数据库·spring boot·gateway·api·springcloud
鸽鸽程序猿8 天前
【JavaEE】【SpringCloud】网关_GateWay
spring cloud·java-ee·gateway
短剑重铸之日8 天前
《SpringCloud实用版》 Gateway 4.3.x 保姆级实战:路由 + 限流 + 鉴权 + 日志全覆盖
java·后端·spring cloud·架构·gateway
一条咸鱼_SaltyFish12 天前
WebFlux vs MVC:Gateway集成若依框架的技术选型之争
java·开发语言·微服务·gateway·mvc·开源软件·webflux
亚林瓜子13 天前
AWS API Gateway添加OAuth2请求头传递app id信息
云计算·gateway·aws·oauth2·请求头·principalid