I will soon be using a server named Undertow. The website says:
Undertow is a flexible performant web server written in java, providing both blocking and non-blocking API’s based on NIO
If Undertow allows non-blocking, is that the same as node.js? I don't mean the languages or anything like that. I have a separate project where I thought node.js would have been a good choice, but if I can use a single product for multiple projects it would be helpful.
EDIT: I found this question. Java NIO non-blocking mode vs node.js asychronous operation And I am starting to think I have confused things.
Undertow is based on the JBoss XNIO library and like Nodejs, XNIO relies on operating system capabilities (epoll or kqueue when available) to be notified for IO events (when data is available to read from a socket for example).
In Undertow, accepting incoming requests is done following this model, by the IO threads
. Doing blocking operations on these threads would mean delaying the handling of new incoming requests. See Undertow's documentation on IO threads
Next to the IO threads, Undertow manages another thread pool, the Worker threads
, to handle blocking tasks (think of tasks like calling a webservices or querying a database.) And this is what you wont get with Nodejs!
To use a Worker thread, the request handling has to be dispatched from the IO thread. The API is comprehensive and easy to use, again, see Undertow's documentation, as a starting point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With