서비스 디스커버리 (Eureka) 와 Server/Client 설정 방법

2026. 6. 26. 11:22·MSA

1. 서비스 디스커버리(Service Discovery)란?

  • 마이크로서비스 아키텍처에서 각 서비스의 위치를 동적으로 관리하고 찾아주는 기능이다.
  • 주요 기능: 서비스 등록/조회, 헬스 체크 등.

2. 헬스 체크 및 장애 처리

헬스 체크

  • Eureka 서버가 주기적으로 서비스 인스턴스의 상태를 확인하여 가용성을 유지한다.
  • 기본 헬스 체크 엔드포인트 /actuator/health 를 사용하여 주기적으로 체크한다.

장애 처리

  • 서비스 장애 시 Eureka 서버는 해당 인스턴스를 레지스토리에서 제거하여 다른 서비스의 접근을 차단한다.

3. Eureka 설정 방법

spring-cloud-starter-netflix-eureka-client 의존성이 필요하고, 애플리케이션 이름만 설정파일에 있다면 Eureka에 등록이 된다.

 

총 3개의 APP을 사용하여 관리한다. (Server - client1, client2)

 

build.gradle(Server)

dependencies {
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

application.properties(Server)

spring.application.name=server

server.port = 19090

eureka.client.register-with-eureka=false
// 이 설정을 통해 Eureka 서버로만 작동할 거니까 클라이언트용 기능은 다 끈다는 의미
eureka.client.fetch-registry=false

eureka.instance.hostname=localhost

eureka.client.service-url.defaultZone=http://localhost:19090/eureka/

 

ServerApplication.java (Server)

@SpringBootApplication
@EnableEurekaServer // 이 어노테이션을 사용해야 Eureka 서버로 수행된다.
public class ServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ServerApplication.class, args);
    }

}

 


build.gradle(Client1, 2)

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-webmvc'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

 

 

application.properties(Client1, 2) 

spring.application.name=first // 두번째 Client 는 second 

server.port = 19091 // 두번째 Client 는 19092 

eureka.client.service-url.defaultZone=http://localhost:19090/eureka/

 


실행 화면(http://localhost:19090)

 

 

 

'MSA' 카테고리의 다른 글

API 게이트웨이 (Spring Cloud Gateway)  (0) 2026.06.27
서킷 브레이커 (Resilience4j)  (0) 2026.06.27
로드 밸런싱  (0) 2026.06.26
Spring Cloud란 무엇일까?  (0) 2026.06.25
MSA란 무엇일까?  (0) 2026.06.25
'MSA' 카테고리의 다른 글
  • 서킷 브레이커 (Resilience4j)
  • 로드 밸런싱
  • Spring Cloud란 무엇일까?
  • MSA란 무엇일까?
taeyoon2
taeyoon2
taeyoon2 님의 블로그 입니다.
  • taeyoon2
    taeyoon2 님의 블로그
    taeyoon2
  • 전체
    오늘
    어제
    • 분류 전체보기 (36)
      • 심화_AI를 활용한 백엔드 아키텍처 심화 과정 (24)
      • MSA (11)
      • Study (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    spring cloud config
    심화_AI를 활용한 백엔드 아키텍처 심화 과정
    JWT
    Config
    내일배움캠프
    til
    api gateway
    OAuth2
    사전캠프
    서킷 브레이커
    Resilience4j
    내일배움캠프 #사전캠프 #til
    분산추적
    MSA
    보안구성
    Zipkin
    로드 밸런싱
    RabbitMQ
    spring cloud
    이벤트 드리븐
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.6
taeyoon2
서비스 디스커버리 (Eureka) 와 Server/Client 설정 방법
상단으로

티스토리툴바