zuul retry
This commit is contained in:
@@ -22,7 +22,7 @@ management:
|
||||
|
||||
eureka:
|
||||
server:
|
||||
enable-self-preservation: false # 일시적인 네트워크 장애로 인한 서비스 해제 막기 위한 자기 보호 모드 (디폴트 true, 운영에선 반드시 true 로 설정 필요)
|
||||
enable-self-preservation: true # 일시적인 네트워크 장애로 인한 서비스 해제 막기 위한 자기 보호 모드 (디폴트 true, 운영에선 반드시 true 로 설정 필요)
|
||||
response-cache-update-interval-ms: 30000 # 유레카 서버의 캐싱 업데이트 주기 (디폴트 30,000ms)
|
||||
eviction-interval-timer-in-ms: 60000 # 클라이언트로부터 하트비트가 계속 수신 되는지 점검 (디폴트 60,000)
|
||||
wait-time-in-ms-when-sync-empty: 3000 # 유레카 서버가 시작되고 유레카 피어링 노드로부터 Instance 들을 가져올 수 없을 때 기다릴 시간 (디폴트 3000ms, 운영 환경에선 삭제 필요)
|
||||
@@ -31,7 +31,8 @@ eureka:
|
||||
register-with-eureka: false
|
||||
fetch-registry: false
|
||||
serviceUrl:
|
||||
defaultZone: http://peer2:8763/eureka/
|
||||
# defaultZone: http://peer2:8763/eureka/ # 피어링 시 필요
|
||||
defaultZone: http://peer1:8762/eureka/
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
||||
@@ -65,9 +65,17 @@ public class EventController {
|
||||
return "[EVENT] Gift is " + gift;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "timeout")
|
||||
public String timeout() {
|
||||
|
||||
sleep();
|
||||
return "[EVENT] good";
|
||||
}
|
||||
|
||||
private void sleep() {
|
||||
try {
|
||||
Thread.sleep(7000); // 7,000 ms (7초), 기본적으로 히스트릭스는 1초 후에 호출을 타임아웃함
|
||||
Thread.sleep(10000); // 7,000 ms (7초), 기본적으로 히스트릭스는 1초 후에 호출을 타임아웃함
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,12 @@
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 히스트릭스 -->
|
||||
<!--<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
@@ -2,13 +2,12 @@ package com.assu.cloud.zuulserver;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
||||
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableZuulProxy // 주울 서버로 사용
|
||||
//@EnableCircuitBreaker
|
||||
public class ZuulserverApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -37,20 +37,6 @@ eureka:
|
||||
lease-expiration-duration-in-seconds: 90
|
||||
prefer-ip-address: true # 서비스의 호스트 이름이 아닌 IP 주소를 유레카 서버에 등록하도록 지정 (디폴트 false)
|
||||
|
||||
|
||||
#eureka:
|
||||
# instance:
|
||||
# prefer-ip-address: true
|
||||
# lease-renewal-interval-in-seconds: 3
|
||||
# lease-expiration-duration-in-seconds: 2
|
||||
# client:
|
||||
# register-with-eureka: true # 레지스트리에 자신을 등록할지에 대한 여부 (디폴트 true)
|
||||
# fetch-registry: true # 레지스트리에 있는 정보를 가져올지에 대한 여부 (디폴트 true)
|
||||
# registry-fetch-interval-seconds: 3
|
||||
# disable-delta: true
|
||||
# serviceUrl:
|
||||
# defaultZone: http://peer1:8762/eureka/
|
||||
|
||||
zuul:
|
||||
ignored-services: '*' # 유레카 기반 모든 경로 제외
|
||||
prefix: /api # 정의한 모든 서비스에 /api 접두어
|
||||
@@ -58,17 +44,35 @@ zuul:
|
||||
event-service: /evt/**
|
||||
member-service: /mb/**
|
||||
sensitive-headers: Cookie,Set-Cookie # 주울이 하위 서비스에 전파하지 않는 헤더 차단 목록 (디폴트는 Cookie, Set-Cookie, Authorization)
|
||||
retryable: true # 디폴트 false
|
||||
|
||||
event-service: # 이 부분이 없으면 전체적으로 설정 적용
|
||||
ribbon:
|
||||
MaxAutoRetries: 0 # 첫 시도 실패시 같은 서버로 재시도 하는 수 (첫번째 전송은 제외)
|
||||
MaxAutoRetriesNextServer: 1 # 첫 시도 실패시 다음 서버로 재시도 하는 수 (첫번째 전송은 제외)
|
||||
# ReadTimeout: 1000 # HttpClient 의 Read Timeout (데이터를 읽어오는 과정의 Timeout 시간)
|
||||
# ConnectTimeout: 2000 # HttpClient 의 Connection timeout (연결과정의 Timeout 시간)
|
||||
ReadTimeout: 1000 # HttpClient 의 Read Timeout (디폴트 1,000 ms, 데이터를 읽어오는 과정의 Timeout 시간)
|
||||
ConnectTimeout: 1000 # HttpClient 의 Connection timeout (디폴트 1,000 ms, 연결과정의 Timeout 시간)
|
||||
|
||||
hystrix:
|
||||
command:
|
||||
default: # 유레카 서비스 ID
|
||||
default:
|
||||
circuitBreaker:
|
||||
sleepWindowInMilliseconds: 5000 # 서킷 브레이커가 열린 후 서비스의 회복 상태를 확인할 때까지 대기할 시간 간격. 즉, 서킷 브레이커가 열렸을 때 얼마나 지속될지...(디폴트 5000)
|
||||
errorThresholdPercentage: 50 # 서킷 브레이커가 열린 후 requestVolumeThreshold 값만큼 호출한 후 타임아웃, 예외, HTTP 500 반환등으로 실패해야 하는 호출 비율 (디폴트 50)
|
||||
requestVolumeThreshold: 10 # 히스트릭스가 호출 차단을 고려하는데 필요한 시간인 10초(metrics.rollingStats.timeInMilliseconds) 동안 연속 호출 횟수 (디폴트 20)
|
||||
metrics:
|
||||
rollingStats:
|
||||
timeInMilliseconds: 10000 # 서비스 호출 문제를 모니터할 시간 간격. 즉 서킷 브레이커가 열리기 위한 조건을 체크할 시간. (디폴트 10초)
|
||||
# 설정한 시간 간격동안 통계를 수집할 횟수 (디폴트 10, 이 버킷수는 모니터 시간 간격에 균등하게 분할되어야 함)
|
||||
# 여기선 10초 시간 간격을 사용하고, 3초 길이의 5개 버킷에 통계 데이터 수집
|
||||
numBuckets: 5
|
||||
execution:
|
||||
isolation:
|
||||
thread:
|
||||
timeoutInMilliseconds: 5000 # 히스트릭스 타임아웃 5초로 설정 (기본 1초, ribbon 의 타임아웃보다 커야 기대하는 대로 동작함)
|
||||
event-service:
|
||||
ribbon:
|
||||
ReadTimeout: 5000 # 리본 타임아웃 5초로 설정 (기본 5초)
|
||||
timeoutInMilliseconds: 4100 # 히스트릭스 타임아웃 5초로 설정 (기본 1초, ribbon 의 타임아웃보다 커야 기대하는 대로 동작함)
|
||||
|
||||
logging:
|
||||
level:
|
||||
com.netflix: DEBUG
|
||||
|
||||
Reference in New Issue
Block a user