Aryan Singh
Aryan Singh

Reputation: 93

Will using Virtual Threads Java 21 coupled with @Async and CompletableFuture help improve the response time of the APIs?

I am currently working on an a microservice of an e-commerce application built in Spring-boot Web-mvc which uses a third party SDK to get/update information regarding Cart/Catalog/Inventory, etc. But the problem is some of the service methods have upto 5 sequential calls to the SDK methods (which off-course calls APIs internally). This results in increase in the response times of the APIs exposed by this microservice. To mitigate this, I have been exploring Java's CompletableFuture and have made some sdk method calls parallel using this.

But still, there is no significant increase in the response times of the APIs.

Will enabling virtual threads in the application and making all service methods @Async help in decreasing the response times of various APIs exposed by the application.

Also does returning CompletableFuture directly from the Rest Controllers beneficial and a better practice ?

Upvotes: -1

Views: 39

Answers (0)

Related Questions