Notion 旅遊行程同步

Notion 旅遊行程同步 An architecture diagram generated by Archify. 後台 · 產生連結 · HMAC session · Architecture component 後台 產生連結 · HMAC session 行程頁 · 唯讀 / 編輯分享連結 · Architecture component 行程頁 唯讀 / 編輯分享連結 Google 我的地圖 · iframe 延遲載入 · Architecture component Google 我的地圖 iframe 延遲載入 Cloudflare + nginx · trip.relexes.com · GCP VM line-bot · 容器上限 64MB Cloudflare + nginx trip.relexes.com 圖片磁碟快取 · volume trip_data · GCP VM line-bot · 容器上限 64MB 圖片磁碟快取 volume trip_data trip-app · Go 單一 binary · 內嵌靜態頁 · GCP VM line-bot · 容器上限 64MB trip-app Go 單一 binary · 內嵌靜態頁 SQLite · 快照 · token · 內文快取 · GCP VM line-bot · 容器上限 64MB SQLite 快照 · token · 內文快取 Notion 圖片主機 · 網址約一小時過期 · Architecture component Notion 圖片主機 網址約一小時過期 Notion API · 行程資料的真相來源 · Architecture component Notion API 行程資料的真相來源 HTTPS · SSE 後台 API iframe 只放行 Cloudflare 來源 快照與 token 寫回(操作當下) 輪詢拉回變更 串流下載 落檔不解碼 GCP VM line-bot · 容器上限 64MB Legend Frontend Backend Database Cloud Security External

兩個方向不對稱

  • • 網頁改動在使用者操作當下寫回 Notion,成功才更新本地快照
  • • Notion 端的變更靠輪詢,有人在看才每 30 秒查一次,變更用 SSE 推播
  • • Notion 是唯一真相:下一輪同步會覆蓋任何本地未送出的差異

Notion API 的限制

  • • client 端限流 3 rps,429 讀 Retry-After 退避;POST 不重試避免重複建立頁面
  • • 圖片網址約一小時過期,快照只存 block id,改走本站代理並限定來源網域
  • • 排序一次發多筆 PATCH,全部成功才廣播快照,中途失敗就強制重新完整同步

64MB 記憶體內

  • • 圖片串流落檔,不解碼不縮圖,同一張並發只下載一次
  • • 內文預熱每筆間隔 400ms,把 API 額度讓給即時請求
  • • GOMEMLIMIT 設 48MiB 讓 Go 提早 GC,而不是等容器被 OOM kill