What is the difference between asynchronous and synchronous HTTP request?

Webserver

Webserver Problem Overview


What is the difference between asynchronous and synchronous HTTP request?

Webserver Solutions


Solution 1 - Webserver

Synchronous: A synchronous request blocks the client until operation completes. In such case, javascript engine of the browser is blocked.

Asynchronous An asynchronous request doesn’t block the client i.e. browser is responsive. At that time, user can perform another operations also. In such case, javascript engine of the browser is not blocked.

Solution 2 - Webserver

Check out https://stackoverflow.com/questions/5971301/determining-synchronous-vs-asynchronous-in-web-applications for previous discussion. In short:

> Asynchronous APIs do not block. Every synchronous call waits and blocks for your results to > come back. This is just a sleeping thread and wasted computation.

Solution 3 - Webserver

Sachin Gandhwani's answer is very well explained in simple words. In case you are still not convinced with the difference of asynchronous HTTP request and synchronous HTTP request, you can read this - https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests

Solution 4 - Webserver

Asynchronous APIs do not block. Every synchronous call waits and blocks for your results to come back. This is just a sleeping thread and wasted computation.

If you need something to happen, send an asynchronous request and do further computation when the request returns. This means your thread sits idle and can pick up other work.

Asynchronous requests is the way to scale to thousands of concurrent users.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAbhimanyu KumarView Question on Stackoverflow
Solution 1 - WebserverSachin GandhwaniView Answer on Stackoverflow
Solution 2 - WebserverFrank CaronView Answer on Stackoverflow
Solution 3 - Webserveraakanksha_02View Answer on Stackoverflow
Solution 4 - WebserverShiv Kumar SinghView Answer on Stackoverflow