Skip to content

problem read model 성능 개선 #136

@huhdy32

Description

@huhdy32

high

mapInfos 메서드 내에서 memberClient, schoolClient, courseClient를 순차적으로 호출하고 있습니다. 이 클라이언트 호출들은 서로 독립적이므로 CompletableFuture를 사용하여 병렬로 실행하면 I/O 대기 시간을 줄여 성능을 크게 향상시킬 수 있습니다. 특히 페이지 조회 시 여러 문제에 대해 이 메서드가 호출되므로 성능 개선 효과가 클 것입니다.

        final var memberInfoFuture = java.util.concurrent.CompletableFuture.supplyAsync(() -> memberClient.getMemberInfo(problem.memberId()));
        final var schoolInfoFuture = java.util.concurrent.CompletableFuture.supplyAsync(() -> schoolClient.getSchool(RequestType.JSON.getType(), problem.schoolCode())
            .orElse(SchoolInfo.none()));
        final var courseResultFuture = java.util.concurrent.CompletableFuture.supplyAsync(() -> courseClient.getParentCourses(problem.path()));

        java.util.concurrent.CompletableFuture.allOf(memberInfoFuture, schoolInfoFuture, courseResultFuture).join();

        return ProblemResponse.from(problem, memberInfoFuture.join(), schoolInfoFuture.join(), courseResultFuture.join());

Originally posted by @gemini-code-assist[bot] in #135 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions