Instant notifications like Facebook

前端 未结 3 959
無奈伤痛
無奈伤痛 2020-12-23 22:32

I am building a social application and was wondering how facebook achieve their notifications. As you know, facebooks notifications are instant. As soon as someone takes an

3条回答
  •  执念已碎
    2020-12-23 23:13

    Facebook uses a messaging protocol (which it designed) called Thrift. This allows notifications from clients to servers with very low latency. I would imagine updates on the server would be triggered depending on the user action and relevant users that are logged in would be notified by the same mechanism.

    Using a messaging protocol such as thrift (also see Protocol buffers) clients don't have to poll the server for updates, instead the server can push notifications to clients. To do this the server needs to have a notion of who is logged in at any one time (Login, logout handshaking) and of them, who should receive notifications from a particular client action.

    Easier said than done, especially when you have 800 million potential users logged in!

提交回复
热议问题