強制 Facebook 的「時間軸」依照時間排序

TechCrunch 的「How I cured my tech fatigue by ditching feeds」這篇提到了 Social Network 成隱的問題:

Many people have deleted the Facebook app from their phone to avoid this mindless habit. “What’s going on in my feed?” they think. Then they scroll, scroll, scroll, get bored and close the app. Repeat this process every 30 minutes. Deleting the app is the best way to take a stance and say that Facebook is a waste of time.

砍掉 Facebook 是一個還不錯的方法,但如果還是有使用 Facebook 需求,就只好想辦法降低 Facebook 帶來的影響。其中我找的方法是強制切到 Most Recent 版本,降低 Facebook 演算法的介入。

昨天剛好在重新處理機器,發現之前用的那個 Google Chrome 套件不見了,只好找看看有沒有替代方案,後來翻到這個:「Facebook Most Recent News Feed」。

如果看裡面程式碼,其實做的事情很簡單,就是硬切過去:

chrome.webRequest.onBeforeRequest.addListener(
    function(info) {
        if (info.url === 'https://www.facebook.com/') {
            return {
                redirectUrl: 'https://www.facebook.com/?sk=h_chr'
            }
        }
    }, {
        urls: [
            "https://www.facebook.com/*"
        ],
        types: ["main_frame"]
    }, ["blocking"]
);

當然,如果能考慮整個移除的話也是不錯啦...

Facebook 因為 Connection Pool 選擇機制,加上系統的複雜性而導致的慘案...

Facebook 的 engineer 寫了一篇文章,說明他們花了超過兩年的時間找到一個 bug:「Solving the Mystery of Link Imbalance: A Metastable Failure State at Scale」。

整個故事是個通靈的故事...

Facebook 在底層的架構使用了 Link Aggregation 的規劃,多條線路 channel bonding 在一起連到骨幹上。但發現有時候會卡在某一條線路壅塞而導致 system failure。

於是就一路追下去,從 switch 本身開始懷疑,最後去組織跨部門的研究小組跳下去分析 (通靈)。後來才觀察到是因為 connection pool 的機制本身用的演算法在 Facebook 這個複雜的系統架構下造成的慘案...

當 query burst 發生時,Facebook 的系統會同時到 50~100 組資料庫撈資料出來寫入 cache,而 connection pool 的機制用的是 MRU (Most Recently Used),從 congestion link 回來的 connection 會在 pool 裡面的最上方,於是就愈來愈塞...

知道問題後,解決的方法就簡單多了。只是把 connection 選擇演算法從 MRU 換成 LRU 後就解決了,但中間用了超過兩年的時間,以及至少 30 個人的努力才把問題找出來並且解決。

可以看到最後銘謝的對象一卡車:

Thanks to all of the engineers who helped us manage and then fix this bug, including James Paussa, Ernesto Ovcharenko, Mark Drayton, Peter Hoose, Ankur Agrawal, Alexey Andreyev, Billy Choe, Brendan Cleary, JJ Crawford, Rodrigo Curado, Tim Eberhard, Kevin Federation, Hans Fugal, Mayuresh Gaitonde, CJ Infantino, Mark Marchukov, Chinmay Mehta, Murat Mugan, Austin Myzk, Gaya Nagarajan, Dmitri Petrov, Marco Rizzi, Rafael Rodriguez, Steve Shaw, Adam Simpkins, David Swafford, Wendy Tobagus, Thomas Tobin, TJ Trask, Diego Veca, Kaushik Veeraraghavan, Callahan Warlick, Jason Wilbanks, Jimmy Williams, and Keith Wright.

最後附上 Facebook 解釋的圖: