Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST web services: synchronous or asynchrous?

What is the default behavior of REST web services - synchronous or asynchronous?
If it's synchronous then can we create asynchronous?

like image 904
Ajit Avatar asked Apr 17 '13 12:04

Ajit


People also ask

Are REST API synchronous or 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.

Does REST support asynchronous?

Asynchronous pattern for REST services is currently not supported in this release.

Are web services synchronous or asynchronous?

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.

Are all Web APIs asynchronous?

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.


1 Answers

"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:

  • Client constructs an HTTP structure, sends over the socket connection.
  • Waits for the response HTTP.

Asychronous behaviour:

  • Client constructs HTTP structure, sends the request, and moves on.
  • There's another thread that is waiting on the socket for the response. Once response arrives, the original sender is notified (usually, using a callback like structure).
like image 51
UltraInstinct Avatar answered Sep 29 '22 22:09

UltraInstinct