The popular Facebook is developed with PHP. With some technical exchanges, we will gradually see the experiences shared by Facebook technicians. Recently, this geeksessions site has seen the documents shared by Facebook's Lucas nealan for reference.
Cache is king
Any successful website has a set of best-suited cache policies.
Note: This hierarchical picture is not strictly top-down.
The alternative "> PHPCache, APC
On average, every Facebook user accesses more than 50 pages a day, so it is important to optimize the loading time of PHP pages. On the "> PHP cache layer, Facebook uses APC.
Lucas nealan's "> In the PPT, for example, the time displayed on a page is reduced from over 4000 milliseconds to over 100 milliseconds. In APC. Stat disabled mode, the performance is better. However, you need to restart or use apc_cache_clear () to notify you of updates.
Memcached Layer
APC cache contains non-user-related information, and user-related data cache is of course in memcached.
Facebook has deployed more than 400 memcached servers, and more than 5 TB of data is stored in memcached. This is the world's largest memcached cluster. Also contributed a lot to memcachedCode, Including UDP support and performance improvement (performance improvement over 20% ).
Program Profiling
Facebook developers use callgrind, APD, xdebug, kcachegrind and other tools to perform benchmark performance tests. Any web project is indispensable and easy to ignore. All developers should be skilled in using these tools.
Supplement: language selection
Why does Facebook choose "> PHP instead of other languages? The phrase Cal Henderson of Flickr shows: "ages's don't scale, architecture scale ".
According to the 80-20 principle, APC and memcached are the most important. In these two stages, the cost/benefit ratio is greater than that in other stages.
(The figure above is taken from the documents of Lucas nealan and the copyright belongs to him)