반응형

 

 

개요


 

서비스 디스커버리는 마이크로 서비스 아키텍처에서 각 서비스의 위치를 동적으로 관리하고 찾아주는 기능이다. 

 

각 서비스는 등록 서버에 자신의 위치를 등록하고 다른 서비스는 이를 조회하여 통신한다. 

 

 

Eureka


 

모든 서비스 인스턴스의 위치를 저장하는 중앙 저장소 역할을 하고 인스턴스의 상태를 주기적으로 확인하여 가용성을 보장한다. 

 

여러 인스턴스를 지원하며 고가용성을 유지할 수 있다. 

 

 

Eureka Server Setting


 

build.gradle

implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'

 

application.yml

server:
  port: 19090

eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://localhost:19090/eureka/
  instance:
    hostname: localhost
  server:
    enable-self-preservation: false

 

register-with-eureka : false (다른 Eureka 서버에 이 서버를 등록하지 않음)

fetch-registry : false (다른 Eureka 서버의 레지스트리를 가져오지 않음)

enable-self-preservation : false (자기 보호 모드 비활성화)

 

 

Eureka Client Setting


 

build.gradle

implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'

 

application.yml

eureka:
  client:
    service-url:
      defaultZone: http://localhost:19090/eureka/
    register-with-eureka: true
    fetch-registry: true
  instance:
    hostname: localhost
    prefer-ip-address: true
    lease-renewal-interval-in-seconds: 30
    lease-expiration-duration-in-seconds: 90

 

register-with-eureka : true (Eureka 서버에 등록)

fetch-registry : true (Eureka 서버로부터 레지스트리 정보 가져오기)

lease-renewal-interval-in-seconds : 리스 갱신 간격

lease-expiration-duration-in-seconds : 리스 만료 시간 

 

728x90
반응형