Polling and Long Polling

    1. Polling: The client sends Ajax requests to the server regularly, and the server returns the response information and closes the connection immediately after receiving the request.
      Advantages: It is easier to write back-end programs.
      Disadvantages: Most of the requests are useless, wasting bandwidth and server resources.
      Example: Suitable for small applications.

    2. Long polling: The client sends an Ajax request to the server, the server holds the connection after receiving the request, returns the response information and closes the connection until there is a new message, and the client sends a new request to the server after processing the response information.
      Advantages: Infrequent requests in the absence of messages.
      Disadvantage: Server holding connections consumes resources.
      Examples: WebQQ, Hi web version, Facebook IM.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325893233&siteId=291194637