Spring/SpringBoot-MSA
SpringBoot MSA (9) - Spring Cloud Gateway / Load Balancer
ChrisMare
2023. 10. 10. 11:26
1. first-service 프로젝트의 환경설정에 서버포트를 랜덤으로 지정
server:
port: 0
spring:
application:
name: my-first-service
eureka:
instance:
hostname: localhost
instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8761/eureka
2. 터미널에서 mvn spring-boot:run을 여러번 하더라도 랜덤으로 포트를 지정하기 때문에 상관없다.
http://localhost:8761/ (결과확인)
api 호출 시 각 인스턴스 마다 한번씩 번갈아가면서 호출된다!