如何在Facebook上快速搜索是如此之快 [英] How come Smart search is so fast in facebook

查看:128
本文介绍了如何在Facebook上快速搜索是如此之快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道Facebook如何在主页上实现搜索功能。一旦我输入a,这个下拉菜单就列出了朋友的名单,它的速度非常快。



我在firebug中看到它发送一个ajax请求给一个的文件。



我想在我的一个webapp中实现相同的功能,但即使我的表只有4个记录,需要一些时间来加载下拉列表。
我所做的是


  1. 发送ajax req与我的搜索参数

  2. 执行sql查询

  3. 使html

  4. 并返回它,所以它将
    替换div

  5. < $>

    解决方案

    Facebook拥有非常昂贵的服务器,使用非常昂贵的CDN(Akamai),并使用像memcached这样的服务器端缓存。 b
    $ b

    如果您可以以合理的准确性预测用户可能搜索的内容(例如已知的朋友和朋友的朋友列表),并在服务器上预先缓存它们,您可以快速完成此操作。如果您首先通过将该网页提供给,并将其缓存在客户端上,那么它将快速闪烁(一旦页面加载)。


    I am wondering how facebook has implemented the search functinality on the home page. as soon as i type 'a' the dropdown comes with the list of friends and its very very fast..

    I saw in firebug that it sends a ajax request to one of its file.

    I wanted to implement the same functionality in one of my webapp but even though my table has just 4 records it takes bit time to load the dropdown. What i have done is

    1. send ajax req with my search parameter
    2. executed sql query
    3. made the html
    4. and returned it so it will replace the div

    解决方案

    Facebook has very expensive servers using a very expensive CDN (Akamai) and uses server-side caching like memcached.

    If you can predict with reasonable accuracy the things the user might search for (e.g. a known friends and friends-of-friends list) and pre-cache them on the server you can do this quickly. If you deliver that list with the webpage in the first place and cache it on the client, it will be lightning fast (once the page is loaded anyway).

    这篇关于如何在Facebook上快速搜索是如此之快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆