Sorry about this stupid question, but I just wanted to get confirmation that my understanding is correct..
When providing a cap based service that is built with node.js, is there only one thread available to handle this request? I.e. If I have a long running service handler this blocks/queues any other caller of this service until it is completed.
And thus if I want multiple requests of that cap service, I need to spawn a second instance of the app?
Was making a test with a forced loop in the on-handler of am action and while this was running, triggered a second call of this action. It shows that this is only processing the second request if the first one left the loop. If I add a second instance of the app, it does immediately process a second request.
And would a similar cap service built with the java Version support multiple threads per one instance? And of so how many and how is this controlled?
This is a general question about differences between Node.js and Java. This is not specific to CAP. CAP just embraces the patterns of the underlying runtime.
Node.js uses the Event Loop concept, which basically processes everything in a single worker thread. This works well, for I/O bound scenarios. For CPU bound scenarios this can cause issues (your endless loop is highly CPU bound ;)). Technically it is possible to start multiple such worker threads in a single Node.js process, but I think the more common approach in Node.js is a scale out to multiple processes.
Java is multithreaded and has a thread model, where a new thread is spawned for each incoming request. In Spring Boot and Tomcat the upper bound of request threads can be configured (https://www.baeldung.com/java-web-thread-pool-config#1-embedded-tomcat). With JDK 21 and virtual threads Java will be able to go for a model that takes up some of the advantages of the event loop approach.
Here is some further reading on these topics: