Skip to content

[FEATURE] Parser stage priority-aware 처리 — Redis ZSET intermediate queue #522

Description

@juhy0987

배경

메타 이슈 #515Phase 2 Sub 4 — Parser stage 가 단일 토픽 (issuetracker.fetched) 소비 + Kafka partition FIFO 라서 priority sub-ordering 부재.

선택된 메커니즘: 옵션 2-C — Redis ZSET intermediate queue

변경 방향

인입 단계 (Kafka → Redis)

  • Parser consumer 가 TopicFetched 메시지를 받으면 Redis ZSET 에 즉시 적재
  • ZSET key: parser:queue (단일) 또는 parser:queue:{priority} (priority 별 분리 — TBD)
  • score 계산: priority × 1e10 + arrival_timestamp_ms (낮을수록 먼저 처리)
  • 적재 직후 Kafka commit — Kafka 가 buffer 가 아닌 transport 역할

처리 단계 (Redis → Worker)

인프라

  • 기존 pkg/redis 활용
  • pkg/queuePriorityZSetQueue 추상화 신설 (Validate/Enrich 가 재사용)
  • 메트릭: queue depth / pop latency / priority 별 처리 비율

완료 조건

  • pkg/queue.PriorityZSetQueue 신설 + Validate/Enrich 가 재사용 가능한 API
  • Parser consumer 가 Kafka 메시지 → ZSET 적재 + Kafka commit
  • Parser worker pool 이 ZSET 에서 pop + 처리
  • Kafka publish 실패 시 RetryScheduler 경유 (Redis 잔존 아님)
  • 단위 테스트: ZSET score 계산 / 동일 priority 내 FIFO 검증
  • 통합 테스트: high priority 가 normal 보다 먼저 처리되는 라이브 시나리오
  • graceful shutdown: ZSET 잔존물은 다음 부팅 시 자동 처리
  • .env.example 갱신: PARSER_ZSET_QUEUE_KEY, PARSER_ZSET_POP_BATCH_SIZE, PARSER_ZSET_MAX_SIZE (overflow 방어)
  • 메트릭 dashboard 추가

위험 / 롤백

  • Redis 부하 증가 — 현재 BufferingProducer (normal/low) 가 사용 중이므로 capacity 사전 점검 필요
  • ZSET overflow 시 정책: 최대 size 도달 → 가장 오래된 low priority 항목 drop + 로그
  • 롤백: feature flag PARSER_PRIORITY_QUEUE_ENABLED=false 로 기존 단일 토픽 경로 복귀

관련

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions