기본 설정 및 옵션
재시도
gRPC 호출 시 응답값이 설정한 에러(Error code)에 해당하는 경우 다시 호출을 시도합니다. 재시도는 재시도 설정 항목에 따라 실행됩니다. API별로 기본적으로 재시도하는 응답과 설정은 다음과 같습니다.
재시도 에러 상태 코드
상세한 내용은 GRPC Github를 참고하시기 바랍니다.
항목 | 설명 |
---|---|
CANCELLED | 호출이 취소된 경우(보통 호출하는 곳에서 취소한 경우에 해당) |
UNKNOWN | 알 수 없는 에러로, 예를 들어 다른 주소에서 받은 상태 값이 해당 주소에서 정의되지 않은 경우 반환 - 또는 응답 오류에 대한 정보를 제공하지 않는 API인 경우를 포함 |
DEADLINE_EXCEEDED | 호출이 완료되기 전에 deadline이 만료됨 |
NOT_FOUND | 일부 요청한 엔티티(예: 파일 또는 경로)를 찾을 수 없음 |
RESOURCE_EXHAUSTED | 일부 리소스가 소진되었거나 사용자당 할당량이 부족하거나 전체 파일 시스템의 공간이 부족한 경우 |
ABORTED | 일반적으로 Sequencer Check에 실패하거나 트랜잭션 중간과 같은 동시성 문제로 작업이 중단된 경우 |
INTERNAL | 내부 오류 |
UNAVAILABLE | 현재 서비스를 이용할 수 없음 |
항목 | 설명 |
---|---|
Jittered | 지연 시간을 임의로 설정할지 여부를 결정 - 대부분 경우에 jitter는 true 로 설정됨 |
InitialRetryDelay | 재시도를 처음 하기 전에 설정할 delay - RetryDelayMultiplier에 따라 조정된 값을 사용 |
RetryDelayMultiplier | 다음 호출 retry delay = 이전 호출의 retry delay * RetryDelayMultiplier |
MaxRetryDelay | retry delay의 제한을 설정 - RetryMultiplier는 retry delay를 이 값을 초과하여 설정할 수 없음 |
InitialRpcTimeout | 처음 RPC에 대한 timeout을 설정 - RpcTimeoutMultiplier에 따라 조정된 값을 사용 |
RpcTimeoutMultiplier | 다음 호출 timeout = 이전 호출의 timeout * RpcTimeoutMultiplier |
MaxRpcTimeout | RPC timeout을 설정 - RpcTimeoutMultiplier는 RPC timeout을 이 값을 초과하여 설정할 수 없음 |
TotalTimeout | logic을 완전히 포기할 때까지, remote call을 계속 시도해야 하는 시간을 최종적으로 control - 이 값이 높을수록, 재시도를 더 많이 실행함 |
Publisher retry settings
API | Retry code | 설명 | Retry setting |
---|---|---|---|
create topic | 503 | UNAVAILABLE | • max attempts : 0 •jittered : true •initial retry delay : 100ms •retry delay multiplier : 1.3 •max retry delay : 60s •initial rpc timeout : 60s •rpc timeout multiplier : 1.0 •max rpc timeout : 60s •total timeout : 60s |
get topic | 409 | ABORTED | |
500 | INTERNAL | ||
503 | UNAVAILABLE | ||
list topics | 409 | ABORTED | |
500 | INTERNAL | ||
503 | UNAVAILABLE | ||
list topic subscriptions | 409 | ABORTED | |
500 | INTERNAL | ||
503 | UNAVAILABLE | ||
update topic | 503 | UNAVAILABLE | |
delete topic | 503 | UNAVAILABLE | |
publish(admin) | 409 | ABORTED | • max attempts : Integer.MAX_VALUE • jittered : true • initial retry delay : 100ms • retry delay multiplier : 1.3 • max retry delay : 60s • initial rpc timeout : 5s • rpc timeout multiplier : 1.3 • max rpc timeout : 60s • total timeout : 60s |
429 | RESOURCE_EXHAUSTED | ||
499 | CANCELLED | ||
500 | INTERNAL | ||
UNKNOWN | |||
503 | UNAVAILABLE | ||
504 | DEADLINE_EXCEEDED | ||
publish | 409 | ABORTED | • max attempts : Integer.MAX_VALUE • jittered : true • initial retry delay : 100ms • retry delay multiplier : 1.3 • max retry delay : 60s • initial rpc timeout : 60s • rpc timeout multiplier : 1.0 • max rpc timeout : 60s • total timeout : 60s |
429 | RESOURCE_EXHAUSTED | ||
499 | CANCELLED | ||
500 | INTERNAL | ||
UNKNOWN | |||
503 | UNAVAILABLE | ||
504 | DEADLINE_EXCEEDED |
Subscriber retry settings
API | Retry code | Description | Retry setting |
---|---|---|---|
create subscription | 14 | UNAVAILABLE | • Initial : 100ms • Multiplier : 1.3 • Max : 60s |
get subscription | 14 | UNAVAILABLE | |
list subscriptions | 14 | UNAVAILABLE | |
seek | 14 | UNAVAILABLE | |
update subscription | 14 | UNAVAILABLE | |
delete subscription | 14 | UNAVAILABLE | |
modify ack deadline | 14 | UNAVAILABLE | |
acknowledge | 14 | UNAVAILABLE | |
pull | 14 | UNAVAILABLE | |
streaming pull | 4 | DEADLINE_EXCEEDED | |
8 | RESOURCE_EXHAUSTED | ||
13 | INTERNAL | ||
14 | UNAVAILABLE |
배치 처리
API 호출 시 메시지를 묶어 배치로 전송할 수 있습니다.
Limit Exceeded Behavior
Flow control 제한을 초과했을 때 사용할 조치
ThrowException
: interactive 시나리오와 커스텀 속도제한을 구현한 애플리케이션에서 유용합니다.Block
: 제한을 초과하지 않고 요청할 수 있을 때까지 기다린다. 개별 요청의 대기시간(latency)이 중요하지 않은 배치 처리에 유용합니다.Ignore
: Flow control을 사용하지 않습니다.
API Batching Settings
항목 | element count threshold | request bytes threshold | delay threshold | FlowControlSettings.limitExceededBehavior |
---|---|---|---|---|
publish(admin) | 100 | 1048576 | 10ms | LimitExceededBehavior.Ignore |
publish | 100 | 1000(=1KB) | 1ms | LimitExceededBehavior.Ignore |
로깅
Netti logging
서버 Ping을 포함한 인바운드/아웃바운드 등에 대한 로그는 기본적으로 남지 않습니다. 단, SLF4J, Log4J2, Log4J의 라이브러리가 Dependency에 포함되어 있는 경우에는 로그가 생성됩니다.
- org.slf4j
- org.apache.logging.log4j
- org.apache.logging.log4j
코드 예제
15:11:03.551 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
15:11:03.560 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
15:11:03.560 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0 - Java version: 17
15:11:03.561 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
15:11:03.562 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
15:11:03.562 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.storeFence: available
Internal logging
Publish 및 StreamingPull에서 요청 및 응답(성공/실패)에 대한 로그를 남길 수 있습니다.
로그는 LoggingProvider 유형을 사용하며, 기본적으로는 로그는 남지 않습니다.
Log output의 종류는 다음과 같습니다.
- DefaultMessageLogger: 콘솔에 로깅
- FileStreamLogger: File output에 로깅
Logger에는 기본적으로 다음 값을 설정할 수 있습니다.
항목 | 설명 |
---|---|
timeUnit | 로그 간격의 시간 단위(millisecond) |
interval | 로그를 남길 시간 간격 |
level | 로그의 레벨 - Default: INFO |
코드 예제
코드 예제
InternalLoggingProvider.newBuilder()
.setMessageLogger(
DefaultMessageLogger.newBuilder()
.setLevel(Level.INFO)
.setTimeUnit(TimeUnit.MILLISECONDS)
.setInterval(logInterval)
.build())