What is an asynchronous server response?

I am reading about a real-time network, and I noticed an allow Django to do async responses suggestion. Until now, I realized that parallelism can be achieved on the client by issuing several Http requests from the same side using Ajax, but for the server, these are only individual requests processed by each user.

As I see it works:

  • The client sends two requests
  • The server receives them and solves them each in its stream and returns to the client

What is a conceptual example of an asynchronous server?

+4
source share
2 answers

HTTP is a blocking, synchronous protocol. This means that the client must wait for a response from the server before it can continue. The server blocks clients from performing any actions; because the customer must wait for a response. After the browser receives the response, the connection is discarded, and then another connection is opened, and the process repeats until all elements of the page are displayed.

This is the network state and nature of the HTTP protocol.

Ajax just creates a background process that does what the browser would do - it still blocks, but the end effect is that the user can still interact with the client. The browser displays something and is not effectively blocked.

A real-time website allows you to have an open socket that is not blocking, asynchronous. Asynchronous means that you do not need to wait for an answer to return - the client is not blocked. You can send several requests, and then, when the server is done with them, it will respond back. You do not need to "wait."

Many of the things you use every day are asynchronous:

  • Any chat application - for example, IRC, facebook messenger, whatapp, etc.
  • A phone conversation with a really chatty friend (usually you wait to hear another person’s answer, but some people just talk and talk ...).
  • Everything that is broadcast, such as YouTube.

Just think about it: “one side does not have to wait to start the transfer again.”

On the network, it is activated in real time, bypassing HTTP restrictions. Here WebSockets and Server Sent Events (SES) .

The first is the standard way to open a full-duplex (i.e. you can send and receive at the same time) channel over TCP.

The second (SES) is still standardized as part of HTML5, but allows the server to send notifications to the client, not the client, which should poll the server for events. Therefore, instead of sending a request to check for updates, the server will inform you when the update will be available - for example, "don’t call me, I’ll call you."

+7
source

Here is a conceptual diagram of how this works, you can see that the server (HTTP server) is responding to async requests from the DIV, so each response can be considered as an asynchronous response.

Due to the fact that the responses come from a server that can serve asynchronously, then the server can be considered asynchronous.

Sequential diagram

BTW, the article / chart comes from a .NET script, AJAX behavior is general, and that is how it works in a general way.

+2
source

All Articles