通过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动态配置,开始老的机器占比达,慢慢调整到新机器上,实现平滑迁移。

相关推荐
smilecold9 小时前
SpringCloud 入门 - Gateway 网关与 OpenFeign 服务调用
spring cloud·gateway
INFINI Labs2 天前
Elasticsearch 备份:方案篇
大数据·elasticsearch·搜索引擎·gateway·snapshot·backup·ccr
纤瘦的鲸鱼3 天前
Spring Gateway 全面解析:从入门到进阶实践
java·spring·gateway
INFINI Labs5 天前
如何使用 INFINI Gateway 对比 ES 索引数据
大数据·elasticsearch·gateway·easysearch
m0_651593917 天前
位置透明性、Spring Cloud Gateway与reactor响应式编程的关系
java·spring cloud·系统架构·gateway
nvd118 天前
使用gateway api来实现GKE 的pods 从外部访问
gateway·googlecloud
罗不俷8 天前
【Kubernetes】(二十)Gateway
容器·kubernetes·gateway
月夕·花晨9 天前
Gateway-过滤器
java·分布式·spring·spring cloud·微服务·gateway·sentinel
Ytadpole11 天前
性能革命的底层逻辑:深入理解 Spring Cloud Gateway 的 Reactor 核心
java·spring·gateway·reactor·响应式编程·cloud
柳贯一(逆流河版)13 天前
Gateway 集成 JWT 身份认证:微服务统一认证的实战指南
微服务·架构·gateway