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

相关推荐
疯狂的维修18 小时前
关于Gateway configration studio软件配置网关
网络协议·c#·自动化·gateway
hadage23318 小时前
--- 统一请求入口 Gateway ---
gateway
波波烤鸭3 天前
深入理解 Gateway 网关:原理、源码解析与最佳实践
java·spring·gateway
DO_Community3 天前
DigitalOcean Kubernetes 现已支持 Gateway API 托管服务
容器·kubernetes·gateway
T_Ghost3 天前
SpringCloud微服务网关Gateway
spring cloud·微服务·gateway
Rysxt_5 天前
Spring Boot Gateway 教程:从入门到精通
spring boot·网关·gateway
月夕·花晨5 天前
Gateway -网关
java·服务器·分布式·后端·spring cloud·微服务·gateway
sanggou5 天前
License 集成 Spring Gateway:解决 WebFlux 非阻塞与 Spring MVC Servlet 阻塞兼容问题
spring·gateway·mvc
摘星编程11 天前
Nginx 502 Bad Gateway:从 upstream 日志到 FastCGI 超时复盘
网络·nginx·gateway·php-fpm·fastcgi
网硕互联的小客服11 天前
504 Gateway Timeout:服务器作为网关或代理时未能及时获得响应如何处理?
运维·服务器·gateway