How to implement blocking code in a non blocking rest resource? #48287
-
After reading extensive documentation, I would like to know the best way to implement the following scenario: We need a REST interface that accesses both a database and a file system in a blocking manner. There are also other requests, which are typically simple and operate in a non-blocking manner. I am seeking advice on how to best handle requests that involve databases and files and consequently take longer to process. Should the REST interface operate in a non-blocking manner running on an IO thread (using virtual threads, uni, multi), or should it run on a worker thread directly and being blocking? An example would be a file upload and download which handles big files:
Alternatively wrapping |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I would start with blocking / worker thread. If the performance and concurrency are enough, you can stop here. If the two blocking operations can be done concurrently, using virtual threads or Mutiny will help reduce the duration of the operation. |
Beta Was this translation helpful? Give feedback.
I would start with blocking / worker thread. If the performance and concurrency are enough, you can stop here.
If the two blocking operations can be done concurrently, using virtual threads or Mutiny will help reduce the duration of the operation.