So, here my suggestion is to retrieve bulk data using multiple threads asynchronously and bind them together after complete the retrieval mechanism. I will show you how can we achieve this using Java. For this first you have to define number of thread we need to use. We can use a executor to adjust the thread pool size. ExecutorService executor = Executors.newFixedThreadPool(2); Now we can do the further implementation. I have two collections user and profile. I need to retrieve both user and profile details using two separate threads. In the above I passed 2 as thread pool size. So these are the two collection retrievals I used for getting user and profile details. private CompletableFuture<User> retrieveUser(ExecutorService executor) { return CompletableFuture.supplyAsync(() -> userRepository.findById(id).orElseThrow(() -> new RuntimeException()), executor); } private CompletableFuture<Profile> retrieveProfile(ExecutorService executor) { r...
As a developer and software engineer I like to share my research knowledge using these blog posts.