6

I don't know how to formally state this question as i don't know what is actually happening here. Whenever any user comments on my post, facebook makes a request like below to display that comment without me doing anything.How do they do it?

https://0-edge-chat.facebook.com/pull?channel=p_100009456028304

This cannot be push notification as they are are making a pull request constantly(i checked using developer tools available in browsers, although i am not sure about if it is push notification or not).They are constantly making a pull request to above URL.What this technology is called? Constant request Can someone please help me understand this. Maybe this question is duplicate and already answered on stack overflow.But as i don't what this is, it's hard to search.(i tried but couldn't find anything)

Sunil Kumar Jha
  • 841
  • 1
  • 8
  • 11
  • It is called Long polling – WizKid May 12 '17 at 19:24
  • From what i have studied today about polling is that they constantly make requests to the server for any updates and once they got it they display it to the client. – Sunil Kumar Jha May 13 '17 at 17:07
  • But there are numerous thing which might get update all at once, so how to do they make request and decides which is the response for which part of page(update they received is for liked.i can assume that they might add a parameter to signify what is this update for)do they really achieve this 'real time' updates like this?or polling is done like this?How can i achieve polling with limited server resources?(as polling might create overhead at server) – Sunil Kumar Jha May 13 '17 at 18:10
  • @WizKid how do i implement long polling for android application? – Sunil Kumar Jha May 14 '17 at 06:20

1 Answers1

4

As correctly said in the comments, this is called Long Polling. In a nutshell, there exist 5 ways to implement real-time updates in a web page:

  1. Web Push
  2. WebSockets
  3. HTTP Streaming
  4. HTTP Long Polling
  5. HTTP Polling

Facebook is using Long Polling, with a poll timeout of 50 seconds. This means that an HTTP request is done by the browser to the server. If no updates are available, the request is kept pending by the server for a maximum of 50 seconds. This way, as soon as an update is available, it can be pushed to the client without waiting for a new client request (as in normal polling).

Alessandro Alinone
  • 4,934
  • 2
  • 18
  • 22
  • I found this one. https://www.usenix.org/conference/srecon17americas/program/presentation/erlich They talk about pub-sub method for likes and commenting in facebook. – sameera madushan Jul 04 '19 at 18:51