#134 Parallel Data Aggregation from Microservices

Companies:
Sberbank
Themes:
SpringSpring CloudPractice

Implement an API composition method whose theoretical execution time approaches 300ms. The method calls three external microservices. Their calls and average response times are shown below:

List<GroupDTO> GroupFeignClient.search(GroupsSearchCriteriaDTO searchDTO); // 200-350ms
UserDTO UserFeignClient.findById(String userId); // 50-160ms
ScoringDTO ScoringFeignClient.findByUserId(String userId); // 100-250ms

@Service
class SuperUserServiceImpl{
    final GroupFeignClient groupClient;
    final UserFeignClient userClient;
    ScoringFeignClient scoringClient;

    SuperUserDTO findById(String userId){
        searchDTO = GroupsSearchCriteriaDTO.builder().userId(userId).build();
        // implement an API composition method whose theoretical time approaches 300ms

        return new SuperUserDTO();
    }
}

class SuperUserDTO {
    String id;
    String name;
    String lastname;
    Float score;
    List<GroupDTO> groups;
}


class UserDTO {
    String id;
    String name;
    String lastname;
    String phone;
    String email;
}

class GroupDTO {
    String id;
    String code;
    String label;
    String division;
    String description;
    String email;
}

class ScoringDTO {
    String userId;
    Float score;
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in