What is the default behavior of REST web services - synchronous or asynchronous?
If it's synchronous then can we create asynchronous?
REST clients can be implemented either synchronously or asynchronously. Both MicroProfile Rest Client and JAX-RS can enable asynchronous clients. A synchronous client constructs an HTTP structure, sends a request, and waits for a response.
Asynchronous pattern for REST services is currently not supported in this release.
Synchronous means that you call a web service (or function or whatever) and wait until it returns - all other code execution and user interaction is stopped until the call returns. Asynchronous means that you do not halt all other operations while waiting for the web service call to return.
Yes in Web Api, every request has its own thread, but threads can run out if there are many consecutive requests. Also threads use memory so if your api gets hit by too many request it may put pressure on your system. The benefit of using async over sync is that you use your system resources wisely.
"Synchronous" or "Asynchronous" is the behaviour of the client that is requesting the resource. It has nothing to do with REST webservice, its structure, or the supporting server.
Synchronous behaviour:
Asychronous behaviour:
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