← 回到 Reading
ByteByteGo 2026-09-08

Built for Reliability: How American Express Processes Payments at Scale

American Express 在交易過程中扮演連接收單行(acquiring banks)與發卡機構(card issuers)的核心支付網路。2018 年,該公司開始將其平台現代化遷移至 cloud-native 基礎設施,從專為 continuous uptime 設計的硬體,轉向非預期伺服器故障極為常見的環境。由於嚴格的 low-latency 需求與擴展限制,傳統的 event-driven processing 與 monolithic 設計均被捨棄。相反地,工程團隊採用了植基於 cell-based architecture 的設計,以隔離故障並維持即時效能。在 cell-based architecture 中,cell 是一個完整且自給自足的 application stack 副本,旨在作為獨立的 failure domain 運作。每個 cell 擁有自身所需的組件——例如 microservices、資料庫與基礎設施——並避免在 critical execution path 上產生同步的 cross-cell 依賴。與依照 functional domain 切分系統的 microservices 不同,cell 是依 failure boundaries 來劃分架構。American Express 的工程師圍繞特定的即時交易旅程(real-time transaction journeys)構建這些邊界,以隔離故障並維持平台可用性。American Express 在其 cellular 架構中根據變更頻率將資料分類為 immutable、semi-static 或 dynamic,以此管理 data locality。Immutable 與 semi-static 資料會在交易發生前主動推送到所有 cell,以防止 cold cache 帶來的效能懲罰,並消除外部同步呼叫。對於每次交易都會更新的 dynamic 資料,該架構顛覆了既有範式,透過 deterministic routing 將交易導向資料所在之處。由 Global Transaction Router 處理,路由決策源自交易屬性以維持一致性,同時 asynchronous replication 在背景執行以供 failover 使用。

閱讀原文 ↗
目錄 9 段
  1. 01Core Payments 生態系
  2. 02Cell 邊界 (Cell Boundaries)
  3. 03Data Locality
  4. 04Global Transaction Router
  5. 05Credit Card Authorization Flow
  6. 06Mid-Transaction Failure
  7. 07Recovery Semantics
  8. 08Design Tradeoffs
  9. 09結論

Core Payments 生態系

American Express 在交易過程中扮演連接收單行與發卡機構的核心支付網路。2018 年,該公司開始將其平台現代化遷移至 cloud-native 基礎設施,從專為 continuous uptime 設計的硬體,轉向非預期伺服器故障很常見的環境。由於嚴苛的 low-latency 需求與擴展限制,傳統的 event-driven processing 與 monolithic 設計均被捨棄。相反地,工程團隊採用了植基於 cell-based architecture 的設計,以隔離故障並維持即時效能。

  • American Express 扮演收單行與發卡機構之間的核心支付網路。
  • American Express 於 2018 年開始將其核心支付平台遷移至 cloud-native 基礎設施。
  • Cloud 基礎設施需要針對頻繁且不可控的伺服器故障進行設計,而非依賴高可靠性硬體。
  • Event-driven architecture 被捨棄,是因為核心支付處理需要 low latency 的即時回應。
  • Monolithic architecture 被認為無法滿足該平台的 scaling 需求。
  • 工程團隊選擇了基於 cell-based architecture 的做法,建立在 Service-Oriented Architecture (SOA) 時代內部開發的 pattern 之上。

Cell 邊界 (Cell Boundaries)

在 cell-based architecture 中,cell 是一個完整且獨立的 application stack 副本,設計用來作為獨立的 failure domain。每個 cell 都擁有其所需的組件——例如 microservices、databases 與 infrastructure——並避免在 critical execution path 上產生同步的 cross-cell dependencies。不同於依 functional domain 切分系統的 microservices,cell 是依 failure boundaries 來劃分架構。American Express 的工程師圍繞特定的即時 transaction journeys 來建構這些邊界,以隔離故障並維持平台的 availability。

  • Cell 是一個能夠自給自足的 processing stack 副本,包含在單一 region 內本地處理 transaction 所需的所有 microservices、databases 和 infrastructure。
  • Cell 構成了隔離的 failure domains,可以在進行維護或發生 incident 時脫離輪替(taken out of rotation),而不會中斷更廣泛的平台運作。
  • 同步的 cross-cell dependencies 被嚴格排除在 critical transaction path 之外,儘管 reference data replication 與 observability aggregation 可以跨越 cell。
  • Microservices 是按功能劃分系統,而 cell 則是按 failure boundaries 劃分系統;單一 cell 通常封裝了多個 microservices。
  • American Express 工程師建議圍繞 user journeys 來規劃 cell 的規模(sizing),將即時處理需求與事後處理的 workflows 隔離開來。

Data Locality

American Express 在其 cellular architecture 中,依據變更頻率將資料分類為 immutable、semi-static 或 dynamic 來管理 data locality。Immutable 與 semi-static 資料會在 transaction 發生前主動 push 到所有 cell,以防止 cold cache penalty 並消除外部的同步呼叫。對於每筆 transaction 都會更新的 dynamic 資料,該架構反轉了此典範,使用 deterministic routing 將 transaction 導向資料所在之處。由 Global Transaction Router 處理,routing 決策是衍生自 transaction attributes 以確保一致性,同時 asynchronous replication 在背景運行以支援 failover。

  • American Express 將資料分為三類:immutable、semi-static(變更頻率從數小時到數年不等)以及 dynamic(隨每筆 transaction 變更)。
  • 對於 immutable 與 semi-static 資料,reference data 會事先被 push 並分發到每個 cell,而不是透過 on-demand caching 來 pull。
  • 事先 push 資料可避免 cold-cache fall-through reads,並使 replication 完全位於 critical transaction path 之外。
  • 對於 dynamic 資料,該架構透過將 transaction 路由至資料所在處,而非將資料複製到 transaction 處,從而避免 stale-state 問題。
  • Global Transaction Router 根據 partner、market 和 payment type 等 payload attributes 處理 deterministic routing,並針對其他 use cases 提供基於優先級的 routing(priority-based routing)。
  • Cell 之間的 message-based replication 在背景非同步運行,以確保 failover 的資料 availability,而不會延遲正在進行中的 transactions。

Global Transaction Router

Global Transaction Router 在分散式支付系統中負責路由流量並強制執行跨 cell 的邊界,作為 cell 與外部機構之間唯一的通訊路徑。為了防止這個關鍵組件成為 failure point,American Express 的工程師排除了支付相關的 business logic,將 router 限制在僅進行最基本的 message parsing 以做出 routing 決策。透過使用 non-persistent storage 讓 instances 維持接近 stateless 的狀態、採用非同步 logging 與 configuration 更新,並在各 region 部署並行的 active instances,進一步確保了 resilience。這項設計展示了關鍵的架構瓶頸(structural chokepoints)如何透過刻意的簡潔性與最小化 dependencies 來維持可靠性。

  • Payments mesh 中的 cell 缺乏直接通訊能力,完全依賴 Global Transaction Router 進行 inter-cell 及外部 routing。
  • American Express 的工程師透過排除支付 business logic、避免集中式 data lookups,使 router 保持精簡。
  • Router instances 透過保持近乎 stateless,並將 state 保留在 non-persistent storage 中,以維持 high availability。
  • 具備 buffer truncation 的非同步 logging 機制與基於記憶體的 configuration loading,可防止 transaction 出現瓶頸。
  • 跨多個 regions 的 active-active 部署比 active-standby 更受青睞,以提高 stateless 組件的 availability。

Credit Card Authorization Flow

American Express 的信用卡 authorization 流程展示了由 Global Transaction Router 管理的解耦架構。在收到由商家 point-of-sale 終端發起的交易後,router 會使用 deterministic 或 priority-based routing 將 request 轉發至內部的 processing cell。在 cell 內部,microservices 負責處理 data enrichment、transformation、validation 與 issuer identification,但它們絕不會直接與其邊界外部通訊。相反地,交易會被送回 router,由其與 card issuers 對接,並在將 confirmation 回傳給 acquiring bank 之前,將 response 路由回持有 context 的 cell。

  • point-of-sale 交易首先會透過 Global Transaction Router 進入 American Express 系統。
  • router 會依據 use case,使用 deterministic 或 priority-based routing 將交易導向內部的 processing cells。
  • cell 內部的 microservices 負責處理 validation、enrichment、transformation 以及 issuer determination。
  • Cells 之間保持嚴格隔離,且絕不直接與外部 card issuers 通訊。
  • Global Transaction Router 會與 card issuers 聯繫,並使用 deterministic routing 將 response 路由回持有該交易 context 的特定 cell。

Mid-Transaction Failure

American Express 的支付處理採用 orchestrated microservices 架構來管理 workflows 並監控 service health。當發生 mid-transaction failure 時,orchestrator 會暫停執行並將 request 退回給 Global Transaction Router 以尋找健康的 cell。至關重要的是,系統會捨棄任何已完成的部分工作,並在新的 cell 中從頭重新開始交易。這種設計選擇避免了 cross-cell shared state 與 synchronization 問題,以重新執行 sub-second 交易的微小成本換取 loose coupling。

  • American Express 使用 orchestrator microservice 來監控支付 workflows 並偵測個別 microservices 中的 failure。
  • 當 failure 發生時,交易會被送回 Global Transaction Router 以選擇健康的 cell。
  • American Express 並非從部分進度中恢復,而是捨棄未完成的工作,並從頭重新開始交易。
  • 捨棄部分進度可避免 cells 之間的 shared state,消除 failover 期間的 cross-cell synchronization 問題與 consistency 風險。
  • 每個 cell 都維護自己的 database clusters,並獨立運作,不依賴來自其他 cells 的 state。
  • 重新執行是可行的,因為支付交易在數百毫秒內即可完成,這使得結構性隔離所帶來的微小 latency 成本非常值得。

Recovery Semantics

交易的 recovery semantics 定義了一個 point of no return,在此之前,交易在送達 card issuers 等外部系統前都可以安全地重新啟動或重新路由。American Express 透過將不可逆的步驟延後至支付流程後期來最佳化這一點,以最大化 recoverable window,同時在無法進行 late rerouting 時依賴 idempotency keys 來抑制重複處理。當故障的 cells 恢復時,平台透過快速的 transaction completion、downstream idempotency 重複抑制,以及受控的 percentage-based traffic shifting 來緩解 stale state writes。

  • 在核心生態系統內重新路由交易是安全的,但一旦發送到 card issuers 等外部系統後就不再安全。
  • American Express 透過將 point of no return 盡可能延後至支付處理的後期,來最大化 recoverable window。
  • 交易帶有具一致性的 unique identifiers,downstream 系統會用其來實現 idempotency 與 duplicate suppression。
  • Percentage-based canary shifting 可以在復原期間實現漸進式 cell draining、partial-load validation 以及受控的 failback。
  • 防止已復原的 cells 寫入 stale state,仰賴於交易速度、idempotency identifiers 以及受控步調的 recovery。

Design Tradeoffs

American Express 在其 cell-based 架構中接受了關鍵的 trade-offs,以維持 cell 的獨立性並保護 data integrity。這些 trade-offs 包括跨 cells 複製 service 以消除 cross-cell network hops,以及在平台高負載期間透過 buffer truncation 捨棄非關鍵的 application logs。由於 telemetry 優先寫入本地端並以非同步方式聚合,observability 會出現 latency;此外,若 cross-cell 資料未經驗證,具有 strong consistency 需求的交易可能會被拒絕。歸根結底,將平台分割成獨立單元是以較高的管理複雜度換取 failure 時大幅縮小的 blast radius。

  • American Express 跨 cells 複製 service implementations,以消除 cross-cell network hops 並維持 cell 的獨立性。
  • buffer truncation policy 會在持續高壓期間捨棄 application observability logs,以確保交易處理能持續進行。
  • 全域 dashboard 會出現可見性延遲(visibility lag),因為 metrics、logs 和 traces 在非同步聚合之前,都是先寫入各個 cell 的本地端。
  • 若無法驗證跨 cell 的非同步資料同步,需要強一致性(strong consistency)的 transaction 可能會被拒絕,以保護資料完整性。
  • Cell-based 系統是為了降低故障的 blast radius(爆炸半徑),而不是降低整體的故障頻率,這是以複雜度換取有限的故障影響範圍。

結論

American Express 工程團隊設計了一個具備韌性(resilient)的支付平台,透過確保交易絕不同時依賴多個 cell,使其能在 cell 故障時存活。此架構將資料策略拆分:將靜態 reference data 推送到所有 cell,同時將 transaction 直接導向快速變化的資料。系統的可靠性(dependability)由一個輕量級的 Global Transaction Router 作為支撐,避免在關鍵瓶頸點引入複雜邏輯。平台選擇捨棄局部 transaction 並重新開始,而非跨共享狀態恢復部分作業,並盡可能將 point of no return 推遲,以最大化故障容忍度(failure survivability)。

  • Transactions 彼此隔離,以防止單一 transaction 同時依賴兩個 cell。
  • 變更不頻繁的 reference data 會預先分發到所有 cell,而易變動的資料(volatile data)則保留在本地,並將 transaction 導向該處。
  • Global Transaction Router 透過將其內部邏輯最小化,來維持系統瓶頸點的可靠性(dependability)。
  • 平台選擇重新啟動而非恢復失敗的 transaction,以數百毫秒的 latency 為代價,消除了跨 cell 的共享狀態。
  • 將 point of no return 安排在執行流程的後期,能擴大系統承受故障的容許窗口。