併發處理

  • CDN
  • Load Balance
  • 群集
  • 過濾器
    • 漏斗模型
    • 中間層
    • 用戶認證
    • 反黃牛
  • 限流
    • token bucket
      • 使用一個定時器以恆定速度往桶里頒發令牌,桶滿了則丟棄多餘的令牌
      • "桶"可以用一個整數表示, 資源佔用相對較小
      • 處理速度取決於生產者的速度
      • 允許一定程度的突發流量
    • leaky bucket
      • 在"消費者"一端,以恆定速度消費Queue並處理請求
      • 真正實現恆定速度處理請求, 能夠決定防止突發流量超過下游系統承載能力
      • 需要分配内存資源緩存請求, 增加内存的使用率
    • 控制並發數: channel 緩衝大小 / queue / gatefs
  • 資源監控
  • 資源池
    • 連接池
    • 線程池
  • Cache
    • Redis
  • 異步操作. message queue - MQTT
  • FanOut FanIn 處理
    • 先通過Fan-In進入隊列, 由一個Goroutine消費隊列, 並通過Fan-Out將請求轉發給多個Goroutine來並發操作多個商品的庫存
  • 讀寫分離, 分庫分表, DB 優化
  • 熔斷(當流量過大時 提示系統繁忙, 稍後再試)
  • 邏輯拆分, 虛擬化容器, 提升高可用度

測試

  • 單元測試
  • 流量測試
  • 效能測試 tool
    • internal
      • pprof : on-cpu profile memory goroutine
        • go test -bench=. -benchtime=3s -cpuprofile/memprofile
      • fgprof : on-cpu && off-cpu
      • trace : for runtime bugs
    • external
      • perf : when no pprof

漏斗模型 token leaky concurrency

© Kimi Tsai all right reserved.            Updated : 2023-07-12 09:04:54

results matching ""

    No results matching ""

    results matching ""

      No results matching ""