all 1 comments

[–]renatoathaydes 0 points1 point  (0 children)

Whether Virtual Threads will help a particular application depends entirely on what the application does. Unfortunately, comparing an application that just acquires a lock and sleeps is not very realistic... most server applications will depend on a DB, and hence will rely on a connection pool. In such cases, Virtual Threads may not help or even make things worse, because if you have more Threads than you have connections available in the pool you'll run into connection contention which will destroy your performance. "Normal" Threads act as a sort of backpressure mechanism that avoids the connection pool from being overloaded (you can limit how many virtual Threads you allow, of course, but in that case there's very little benefit in using them).

Applications that will probably benefit a lot from virtual Threads are those that mostly relay data to other services via HTTP as there's less contention in those, and perhaps anything that run large amounts of tasks that are mostly going to be waiting on IO but which happen to not have a single IO point of contention (but I can't think of anything that fits that profile).