Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【将服务从nacos上下线后一直还能接收到请求】Requests continue to be received after the service is offline from nacos #12077

Closed
dxiyang opened this issue May 9, 2024 · 7 comments

Comments

@dxiyang
Copy link

dxiyang commented May 9, 2024

【微服务架构,上层网关,下面有个服务A,服务A启动了两个实例,nacos是集群部署的】The microservice architecture, the upper gateway, has A service A underneath it, and Service A starts two instances, nacos is deployed in clusters

1、【用jemter一直模拟请求,然后将服务A的某个示例下线,按理来说过30秒左右该实例不会收到请求】
Using jemter to simulate requests all the time, and then taking an example of service A offline, the instance should not receive requests after 30 seconds or so
2、【但是经过几轮jmeter测试,只有一两次下线后是正常的,其余的轮次在下线后还会有请求】
However, after several rounds of jmeter tests, only one or two offline are normal, and the rest of the rounds will still have requests after offline

备注:nacos和服务不在一个局域网内

@KomachiSion
Copy link
Collaborator

  1. 网关是否自身有地址缓存,更新频率比较低?
  2. 看nacos的client日志,看下是否已经获取到了新地址。

@dxiyang
Copy link
Author

dxiyang commented May 10, 2024

你好,网关没有地址缓存;

我通过设置如下参数解决了该问题

spring:  
  cloud:
    nacos:
      discovery:
        metadata:
          preserved.heart.beat.interval: 1000 #心跳间隔。时间单位:毫秒。心跳间隔
          preserved.heart.beat.timeout: 3000 #心跳暂停。时间单位:毫秒。 
          preserved.ip.delete.timeout: 3000 #Ip删除超时。时间单位:毫秒。 

有个疑问 ,将上面的参数时间设置变小,会不会影响到naocs,生产用这些参数会产生什么影响??谢谢

@Daydreamer-ia
Copy link
Contributor

preserved.heart.beat.interval 是控制心跳频率的,貌似只对 http 版本的有效,2.x 版本的这个参数无效了
preserved.heart.beat.timeout 是控制实例在没有心跳多久之后被标记为不健康,不健康的实例在没有触发保护阈值之前,查询会被过滤(计算方式:健康实例数 / 总实例数 <= 保护阈值,触发全量推送)
preserved.ip.delete.timeout 是控制实例在没有心跳多久之后会在服务端上摘掉

@dxiyang
Copy link
Author

dxiyang commented May 11, 2024

preserved.heart.beat.interval 这失效了吗 我已经在生产环境改了以上三个参数
三个参数改了后貌似生效了

请教大佬
现在有个疑虑: 这个三个参数改了后会不会对nacos产生压力,导致生产环境nacos挂掉????,生产环境nacos上有50+个服务
@Daydreamer-ia @KomachiSion

@KomachiSion
Copy link
Collaborator

preserved.heart.beat.interval 是控制心跳频率的,貌似只对 http 版本的有效,2.x 版本的这个参数无效了 preserved.heart.beat.timeout 是控制实例在没有心跳多久之后被标记为不健康,不健康的实例在没有触发保护阈值之前,查询会被过滤(计算方式:健康实例数 / 总实例数 <= 保护阈值,触发全量推送) preserved.ip.delete.timeout 是控制实例在没有心跳多久之后会在服务端上摘掉

@dxiyang 人家回复的时候说过了, 2.x的客户端已经无效了, 因为原理上就不同了。

1.x的客户端是通过心跳来续约, 所以需要调整心跳间隔,过期时间, 2.x客户端是长连接保持。不需要心跳

@KomachiSion
Copy link
Collaborator

preserved.heart.beat.interval 这失效了吗 我已经在生产环境改了以上三个参数 三个参数改了后貌似生效了

请教大佬 现在有个疑虑: 这个三个参数改了后会不会对nacos产生压力,导致生产环境nacos挂掉????,生产环境nacos上有50+个服务 @Daydreamer-ia @KomachiSion

是否有压力需要根据你服务端的规格,客户端的版本来评估, 如果是1.x的客户端, 默认值是5000, 15000,30000, 不建议改动的太低,太低的话即使没有压力,也会因为网络波动造成大量抖动。

如果是2.x客户端,那就不用调整了。

@dxiyang
Copy link
Author

dxiyang commented May 15, 2024

我是2.x的客户端,

  • 调整参数前,下线服务A,流量一直还是会进入A服务
  • 调整参数后,下线服务A,过大概30秒后流量就不会进入A服务

上述下线服务异常,我在本地无法复现,但是我们生产环境确实存在,只能通过修改参数让其生效(下线后过大概30秒后不会有流量进入)

@dxiyang dxiyang closed this as completed May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants