There is a bit of a tradeoff with reactive/async programming - you trade simpler, more readable/maintainable code for improved performance.
If you are planning to do blocking operations in a Micronaut REST application, is it considered terrible practice to execute these on the HTTP request serving threads?
If you were to increase the size of the HTTP request serving threadpool in Micronaut so that it was similar in size to that of a regular HTTP framework's thread pool, for example non reactive Spring MVC / Tomcat, would you expect Micronaut's performance characteristics to be similar to those of Spring MVC running on Tomcat?
There is a bit of a tradeoff with reactive/async programming - you trade simpler, more readable/maintainable code for improved performance.
There is almost no performance garante, or immediate gain at least, when moving to an asynchronous or reactive-style programming. This is one of the most common mis-understanding of this programming styles paradigms and they can actually do more harm than good to your application whenever used in the wrong way.
The asynchronous (or reactive) programming promise is scalability, i.e., you application will be able to scale at peak loads way better than a traditional synchronous (blocking) application.
Micronaut has been designed with such considerations in mind while allowing traditional programming style to co-exist with a modern web application building blocks.
When used with Netty, Micronaut will serve your HTTP requests through a non-blocking event-loop, allowing your application to accept (and scale) requests beyond what a traditional Servlet (2.5 ~ event 3.1 with Async
requests) based container would allow.
However, there is a lot of concerns that should be taken into account when using such a model, and Micronaut takes most of the job from your shoulders by - well scheduling resources (CPU) usage - allowing to avoid request blocking.
One of the common, and simple, tricks is to use the @ExecuteOn
annotation whenever your application (or resource endpoint) is going to block on IO operations (network, DB, disk...).