Serving the For You feed

Simon Willison's Weblog

View Original ↗
AI 導讀 technology infrastructure 重要性 3/5

月費 30 美元的客廳遊戲機,用 Go + SQLite 為 7.2 萬人提供 Bluesky 個人化推薦

  • For You Feed 每月只花 30 美元(電費+VPS+域名),理論上可擴展到 100 萬日活用戶
  • 單一 Go 程序 + SQLite 保存 419GB 的 90 天 firehose 資料,跑在客廳 16 核遊戲機上
  • Bluesky 的開放 feed 生態讓任何人都能自建推薦演算法並公開發布給用戶訂閱

一台放在客廳的遊戲電腦,每月電費加 VPS 合計 30 美元,正在為 7.2 萬名 Bluesky 用戶提供個人化推薦 feed——而且理論上這套架構能撐起 Bluesky 全部約 100 萬日活躍用戶的推薦需求。這是 Simon Willison 在 Link Blog 轉介的一篇嘉賓文章,spacecowboy 在 AT Protocol 官方部落格親身說明整套系統怎麼做到的。

Bluesky 允許任何人自建推薦演算法

Bluesky 有一個在主流社群平台中相當罕見的設計:任何人都可以實作自己的「自訂 feed」,並讓其他用戶直接訂閱。這套機制建立在底層的 AT Protocol(去中心化社群協議,Bluesky 的技術基礎)之上,允許 feed 開發者用任意邏輯決定要推薦哪些貼文——從簡單的標籤過濾,到複雜的機器學習排序,完全開放自訂。

這不只是技術上的可能性,而是一個真實運作的生態。spacecowboy 維護的 For You Feed 就是其中最受歡迎的社群自建 feed 之一,目前約有 7.2 萬人使用。不靠大公司、不靠資料中心,一個人在家就能維運一個規模化的推薦服務,正是這篇文章值得一讀的地方。

客廳遊戲機當伺服器:16 核 96GB 的硬體配置

整套系統的主機就是 spacecowboy 客廳裡的一台「遊戲電腦」,硬體規格是 16 核 CPU96GB RAM、外接 4TB NVMe SSD。這個等級放在消費市場屬於高階遊戲或工作站配置,和「企業伺服器」在形象上差距懸殊,但實際跑起來的效能完全夠用。

服務層以單一 Go(Google 開發的高效能編譯語言,常用於網路服務)程序運行,搭配 SQLite(嵌入式關聯式資料庫,不需獨立伺服器程序,整個資料庫就是一個檔案)儲存資料。選擇 SQLite 看似反常——多數生產環境的推薦系統會選用 PostgreSQL 或分散式資料庫,但在這個場景下,SQLite 的低延遲與單檔案設計反而提供了足夠穩定的效能基礎。

Bluesky 全量資料流與 419GB 的 90 天索引

這台 Go 伺服器持續消費 Bluesky 的 firehose(全量即時資料流,平台上所有貼文與互動事件的串流),篩選並寫入相關的互動資料。目前保留最近 90 天的資料,總計佔用約 419GB 的 SQLite 儲存空間。

推薦邏輯的核心是基於喜好的協同過濾(collaborative filtering):「喜歡相同內容的人,還喜歡什麼?」不分析貼文本身的語意,而是透過用戶的喜好行為找出興趣相近群體,再從這個群體的最新互動中挖出你可能也會喜歡的貼文。這套思路並不新鮮,卻在 7.2 萬用戶規模下被一台家用機器實現了。

每月 30 美元:OVH VPS + Tailscale 的成本結構

對外的公共網路流量不直接打到客廳電腦,而是先由一台每月 7 美元OVH(法國雲端服務商)VPS 承接,再透過 Tailscale(基於 WireGuard 協議的 P2P VPN 工具)隧道穿透回家中的主機。這樣做讓客廳主機不需要暴露公開 IP,家用網路頻寬也不必直接承受外部流量衝擊。

整套系統每月支出:電費 20 美元、OVH VPS 7 美元、兩個域名 3 美元,合計 30 美元。spacecowboy 估算,若切換到他們測試過的最輕量演算法版本,現有這套硬體理論上能承載 Bluesky 目前全部約 100 萬日活躍用戶的推薦請求——這個數字讓整套方案的 CP 值顯得格外驚人。

30 美元/月的客廳遊戲機服務 7.2 萬人,Bluesky 的開放 feed 機制正在讓個人開發者做到以前只有大公司才能做的事。

For You Feed 系統規格與每月成本一覽
項目數值
主機 CPU16 核
主機記憶體96GB RAM
NVMe 儲存4TB
SQLite 資料量419GB(90 天)
目前服務用戶7.2 萬人
理論最大承載100 萬 DAU
電費$20/月
OVH VPS$7/月
域名(2 個)$3/月
每月總成本$30

資料來源:AT Protocol 部落格 spacecowboy 嘉賓文章

Abstract

Serving the For You feed One of Bluesky's most interesting features is that anyone can run their own custom "feed" implementation and make it available to other users - effectively enabling custom algorithms that can use any mechanism they like to recommend posts. spacecowboy runs the For You Feed, used by around 72,000 people. This guest post on the AT Protocol blog explains how it works. The architecture is fascinating. The feed is served by a single Go process using SQLite on a "gaming" PC in spacecowboy's living room - 16 cores, 96GB of RAM and 4TB of attached NVMe storage. Recommendations are based on likes: what else are the people who like the same things as you liking on the platform? That Go server consumes the Bluesky firehose and stores the relevant details in SQLite, keeping the last 90 days of relevant data, which currently uses around 419GB of SQLite storage. Public internet traffic is handled by a $7/month VPS on OVH, which talks to the living room server via Tailscale. Total cost is now $30/month: $20 in electricity, $7 in VPS and $3 for the two domain names. spacecowboy estimates that the existing system could handle all ~1 million daily active Bluesky users if they were to switch to the cheapest algorithm they have found to work. Tags: go, scaling, sqlite, software-architecture, tailscale, bluesky