// search query Alice Cooper
A ... they give you a list of A like names Alina, Ana, Alice...
Al .... they limit it to Alicia, Alice, Alina ...
// and so on
The response is an autocomplete Ajax form, but this is not really the question. The key question here is how fast can you search in a text field. Facebook splits this into 2 parts. First they search in the list of your friend which is a cached and relatively rarely changed file containing 100 to a 1000 entries. This is quite fast. The other thing is to search for a name in ALL Facebook, which means I guess 1 billion names. This is a little more tricky, but I guess they have them splitted and indexed by letters or letters combinations. For example:
// search query Alice Cooper
A ... they give you a list of A like names Alina, Ana, Alice...
Al .... they limit it to Alicia, Alice, Alina ...
// and so on
Probably after a 3 letters they are starting to do a search, but not in the 1 billion rows, but in a limited subset of your 3rd level friends and probably increasing it each time.
Probably your query is never compared with the whole table, and there are definitely cached levels or recalculated queries for most of the common names.
This is in terms of technique. In terms of technology take a look at Solandra, a search engine build on top of Cassandra which Facebook is using, though I cannot confirm that this is what they are using, but just to give you a research direction.
发布评论
评论(2)
响应是一个自动完成 Ajax 表单,但这并不是真正的问题。这里的关键问题是在文本字段中搜索的速度有多快。 Facebook 将其分为两部分。首先,他们在您朋友的列表中进行搜索,该列表是一个缓存且相对很少更改的文件,其中包含 100 到 1000 个条目。这速度相当快。另一件事是在 ALL Facebook 中搜索一个名字,这意味着我猜有 10 亿个名字。这有点棘手,但我猜他们将它们分开并按字母或字母组合索引。例如:
可能在 3 个字母之后,他们开始进行搜索,但不是在 10 亿行中,而是在您的第 3 级朋友的有限子集中,并且可能每次都会增加搜索。
可能您的查询永远不会与整个表进行比较,并且对于大多数常用名称肯定存在缓存级别或重新计算的查询。
这是从技术角度来说的。在技术方面,请看一下 Solandra,这是 Facebook 正在使用的基于 Cassandra 构建的搜索引擎,虽然我不能确认这就是他们正在使用的,但只是为了给你一个研究方向。
The response is an autocomplete Ajax form, but this is not really the question. The key question here is how fast can you search in a text field. Facebook splits this into 2 parts. First they search in the list of your friend which is a cached and relatively rarely changed file containing 100 to a 1000 entries. This is quite fast. The other thing is to search for a name in ALL Facebook, which means I guess 1 billion names. This is a little more tricky, but I guess they have them splitted and indexed by letters or letters combinations. For example:
Probably after a 3 letters they are starting to do a search, but not in the 1 billion rows, but in a limited subset of your 3rd level friends and probably increasing it each time.
Probably your query is never compared with the whole table, and there are definitely cached levels or recalculated queries for most of the common names.
This is in terms of technique. In terms of technology take a look at Solandra, a search engine build on top of Cassandra which Facebook is using, though I cannot confirm that this is what they are using, but just to give you a research direction.
我假设底层技术是 AJAX,带有一些缓存机制,可以提高好友列表中个人资料的性能。
I assume the underlying technology is AJAX, with some caching mechanism that increases performance for profiles in your friends list.