n******4 发帖数: 12 | 1 以下摘自http://www.facebook.com/note.php?note_id=14218138919&id=9445547199&index=0
"The naive implementation of sending a notification to all friends whenever
a user comes online or goes offline has a worst case cost of O(average
friendlist size * peak users * churn rate) messages/second, where churn rate
is the frequency with which users come online and go offline, in events/
second. This is wildly inefficient to the point of being untenable, given
that the average number of friends per user is measured in the hundreds, and
the number of concurrent users during peak site usage is on the order of
several millions.
Surfacing connected users' idleness greatly enhances the chat user
experience but further compounds the problem of keeping presence information
up-to-date. Each Facebook Chat user now needs to be notified whenever one
of his/her friends
(a) takes an action such as sending a chat message or loads a Facebook page
(if tracking idleness via a last-active timestamp) or
(b) transitions between idleness states (if representing idleness as a state
machine with states like "idle-for-1-minute", "idle-for-2-minutes", "idle-
for-5-minutes", "idle-for-10-minutes", etc.).
Note that approach (a) changes the sending a chat message / loading a
Facebook page from a one-to-one communication into a multicast to all online
friends, while approach (b) ensures that users who are neither chatting nor
browsing Facebook are nonetheless generating server load."
没怎么看懂这部分,不知道大牛可不可以给解释解释?
作者说第一段中的方法不好,在第二段中提出了改进。不太明白为什么需要做这些。
1. 为什么方法(a)比第一段中的方法要有效呢? 难道这种方法的worst cost不是O(
average friendlist size * peak users * rate)吗?
2. 为什么需要方法(b)? |
|