Skip to content

[BE] 타임아웃 에러 수정 #17

Description

@KK-Hoon

비동기 처리 기능 정리

1. 비동기 작업 종류

1.1 AI 매칭 처리

  • 채용공고-이력서 매칭
  • 이력서-채용공고 매칭
  • 매칭 점수 계산
  • 매칭 결과 저장

1.2 알림 처리

  • 채팅 메시지 알림
  • 지원 상태 변경 알림
  • 매칭 결과 알림
  • 시스템 알림

1.3 파일 처리

  • 이력서 파일 업로드
  • 프로필 이미지 처리
  • 채팅 첨부파일 처리

2. 구현 방식

2.1 Spring Async

@Configuration
@EnableAsync
public class AsyncConfig {
    @Bean
    public Executor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(2);
        executor.setMaxPoolSize(4);
        executor.setQueueCapacity(500);
        executor.setThreadNamePrefix("Async-");
        executor.initialize();
        return executor;
    }
}

2.2 비동기 서비스 구현

@Service
public class AsyncService {
    @Async
    public CompletableFuture<MatchingResult> processMatching(JobPost jobPost) {
        // 매칭 처리 로직
    }

    @Async
    public void sendNotification(Notification notification) {
        // 알림 전송 로직
    }
}

3. 주요 비동기 작업

3.1 AI 매칭 처리

@Async
public CompletableFuture<MatchingResult> processMatching(JobPost jobPost) {
    // 1. 채용공고 텍스트 분석
    // 2. 이력서 텍스트 분석
    // 3. 매칭 점수 계산
    // 4. 결과 저장
    return CompletableFuture.completedFuture(result);
}

3.2 알림 처리

@Async
public void sendNotification(Notification notification) {
    // 1. 알림 생성
    // 2. WebSocket을 통한 실시간 전송
    // 3. 알림 저장
}

3.3 파일 처리

@Async
public CompletableFuture<String> processFile(MultipartFile file) {
    // 1. 파일 검증
    // 2. 파일 저장
    // 3. 파일 처리
    return CompletableFuture.completedFuture(fileUrl);
}

4. 예외 처리

@Async
public CompletableFuture<Result> asyncOperation() {
    try {
        // 비동기 작업 수행
        return CompletableFuture.completedFuture(result);
    } catch (Exception e) {
        return CompletableFuture.failedFuture(e);
    }
}

5. 모니터링 및 로깅

@Async
public void asyncTask() {
    String taskId = UUID.randomUUID().toString();
    log.info("비동기 작업 시작: {}", taskId);
    try {
        // 작업 수행
        log.info("비동기 작업 완료: {}", taskId);
    } catch (Exception e) {
        log.error("비동기 작업 실패: {} - {}", taskId, e.getMessage());
    }
}

6. 제약사항

  • 비동기 작업의 타임아웃 설정
  • 동시 처리 가능한 작업 수 제한
  • 메모리 사용량 제한
  • 에러 발생 시 재시도 정책

7. 성능 고려사항

  • 스레드 풀 크기 최적화
  • 작업 큐 크기 설정
  • 메모리 사용량 모니터링
  • CPU 사용량 모니터링

8. 향후 개선사항

  • 분산 처리 시스템 도입
  • 메시지 큐 시스템 도입 (RabbitMQ, Kafka)
  • 작업 상태 모니터링 대시보드
  • 실패한 작업 자동 재시도
  • 작업 우선순위 설정
  • 작업 취소 기능
  • 작업 진행률 표시
  • 비동기 작업 로그 분석

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions