02-The difference and connection between Nacos and Eureka

The difference between Nacos and Eureka

联系

Nacos和Eureka整体结构类似: All support service registration, service pulling, and health monitoring of service providers using heartbeat methods.

Insert image description here

区别

Nacos supports the server to actively detect the status of the service provider: temporary instances use heartbeat mode, non-temporary instances use active detection mode but put a lot of pressure on the server (not recommended)

  • 心跳模式: The service provider will send heartbeat requests to the Eureka/Nacos server at regular intervals (default 30 seconds) to report its health status.
  • 主动检测模式: Nacos server supports active detection of service providers to determine whether they are down.

Nacos support服务列表变更的消息推送模式 can update the cached service list more timely

  • The Nacos cluster uses AP mode by default. When there are non-temporary instances in the cluster, CP mode is used, while Eureka always uses AP mode.

When a service is registered to Nacos, you can choose to register the service instance as a temporary or non-temporary instance by adding it in the configuration filespring.cloud.nacos.discovery.ephemeralConfiguration choice

  • 临时实例(默认的类型): Use heartbeat detection to determine whether it is down. If the instance is down for a certain period of time, it will be removed from the service list.
  • 非临时实例(永久实例): Nacos actively asks to determine whether it is down. Even if the instance is down, it will not be removed from the service list, but will only be marked as unhealthy.
# 在oreder-service模块的applicaition.yml配置文件中将oreder-service服务注册为永久实例
spring:
  cloud:
    nacos:
      discovery:
        ephemeral: false # 设置为非临时实例(永久实例)

Guess you like

Origin blog.csdn.net/qq_57005976/article/details/134917335