I migrated a Java 17 application to Java 21 and enabled virtual thread for the application.
Microservice Detail:
- 20 requests per second on a container.
- Scaling in switched on for this service. Whenever average CPU hits 30% new container is launched.
- Usually 50 containers are running for this service.
- Without virtual thread, one container used to have an average of 2.5k platform threads running every minute.
- We are using GRPC server on this service.
- Request Detail:
- One requests which is on platform thread, generally uses 6-7 parallel platform thread to fetch data from different data source(I/O).
- We have converted the later 6-7 platform threads to virtual thread using ExecutorService.
- We are not able to move the user request to virtual thread as grcp server does not support it.
When we go live, I can see earlier system used to have 2.5k active platform thread on an avergage. Now it has reduced to 200. But apart from this I am not observing any other benefit.
What I thought, I will observe
- Increase in throughput per container.
- Number of containers used should have reduced as now less context switching because of less active platform threads.
I am seeing no benefit apart from reducing number of platform threads.
What I am missing?
What other parameters I should check which will show improvements?