I want to know about the synchronous apis and asynchronous apis in operating system. What is the difference between them ?
Asynchronous Writes. Synchronous API calls are blocking calls that do not return until either the change has been completed or there has been an error. For asynchronous calls, the response to the API call is returned immediately with a polling URL while the request continues to be processed.
A synchronous client constructs an HTTP structure, sends a request, and waits for a response. An asynchronous client constructs an HTTP structure, sends a request, and moves on. In this case, the client is notified when the response arrives.
Synchronous/asynchronous APIs are application programming interfaces that return data for requests either immediately or at a later time, respectively. Synchronous/asynchronous APIs provide a way to make immediate or scheduled requests for resources, data or services when available.
Web API has a single controller named Customers which have both sync and async actions which we will use for demos.
A synchronous API will block the caller until it returns. An asynchronous API will not block the caller and typically will require a callback which will be executed once the work is completed.
Blocking
Callback
You can have the same in Web APIs. Some APIs will return data in the body of the result of the calls and others will just return (e.g.) a 202 and then do something in the background (processing data, setting up a subscription). Webhooks are then a common way to ping you back when the job you requested is "done".
At 3scale, we use use both synchronous and asynchronous modes with webhooks to avoid people having to couple too tightly to systems.
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