Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What makes facebook pages load so fast [closed]

I am also a php programmer. I always wondered how do Facebook pages load so fast with so many users connecting to them at any instance. My site never reached such speed even when the traffic was less. What do they do so very well for their sites?

What should i take care of even if i want to make a website even half the speed of Facebook. I am referring to php and mysql and jquery websites.

like image 759
Hacker Avatar asked Jan 10 '12 12:01

Hacker


People also ask

Why is Facebook slow but internet is fast?

JavaScript Programming. One of the many reasons behind Facebook's slow speed is the addition of new features to the platform. You might have observed that Facebook slows down after a new update, just like other platforms. Facebook uses JavaScript for most of its programming as it allows interactivity between websites.

How does Facebook load so fast?

According to Gigaom, Facebook uses Autoscale as an intermediary between incoming traffic and the company's servers. During periods of low network traffic, Autoscale distributes this traffic to a smaller number of servers and keeps these servers running at medium capacity.

Why is my Facebook page loading weird?

If you're seeing a problem with how Facebook appears in your web browser, you could have a cache or temporary data issue. If this doesn't solve your issue, it may be because you're using third-party browser extensions. We recommend disabling these add-ons before accessing the site again.

Why does it take forever for a page to load?

Too much traffic: At any given level, a web server can only support requests from a certain number of people. Once that number is surpassed, the page will load slower. The more visitors, the slower the website. With more visitors, the server providers might also need to devote additional resources to the website.


2 Answers

Take a look at this reddit post by someone who interned at Facebook:

http://www.reddit.com/r/programming/comments/nav19/facebook_releases_hhvm_60_percent_faster_than_its/c37pitt

Most relevant parts of the post:

  • Database calls have cache keys. Memcached short-circuits the database hits. Facebook has a > 99.9% hit rate. Occasionally, there can be an issue which causes the hit rate to decrease to 95%. This probably doesn't happen much, but when it did, it made the whole site unusably slow.

  • Stupid database calls that fetch a lot are generally better than smart database calls that fetch minimally. Why? Because most of the stupid database calls are the same - and therefore very cacheable - and using server resources to filter stuff out is therefore much more economical than using database resources. Or, in other words, it lessens the complexity of the database calls and makes fewer at the expense of more data per database call, and more of the load shifted to memcached.

like image 124
Shawabawa Avatar answered Oct 04 '22 21:10

Shawabawa


Facebook has very highly tuned caching and a highly tweaked MySQL cluster setup. Try searching 'MySQL at Facebook' within Facebook. Some of their hints and tips are legendary!

Without knowing what your site is, how its coded, the database structure etc it would be impossible to say how to optimise your site.

Working with big databases day in day out even the most insignificant change to a query can have massive implications to performance. Don't just slap an index across a whole table, use a decent index engine such as Sphinx not just the internal MySQL index. Optimise all your database calls to within a nats hair of their lives.

Also configure MySQL logging for slow_queries etc.

O'Reilly do a couple of good ebooks on performance MySQL.

Dave

like image 22
detheridge02 Avatar answered Oct 04 '22 23:10

detheridge02