tags: Linux, SRE

SRE 讀書會 Round 4 #14 - 線上讀書會共筆

活動資訊


現場共筆

41 | 案例篇:如何優化 NAT 性能?(上) 8 Kyle

42 | 案例篇:如何優化 NAT 性能?(下) 22 Kyle

網路延遲時:路由,網路封包分析,

NAT:

    1. 將IP改寫,用來解決外部ip不夠的問題(public ip)
    1. 支持TCP lb
    1. 內部外部ip mapping

NAT TYPE:

    1. Full cone NAT:
    1. Address-restricted cone NAT
    1. sym

NAT 映射類型

  • 靜態
  • 動態
  • NAPT
    • SNAT
    • DNAT
    • 雙向地址轉換,同時使用 SNAT 和 DNAT

Packet flow in Netfilter and General Networking : iptable經典圖

iptable nat chain:

  • prerouting
  • postrounting
  • output

Masquerade 補充

  • SNAT: 內主動發起
    • Status
    • conntrack
  • DNAT: 外部主動
    • Status
    • conntrack

直接改 封包,沒有剝一層

如果是 Tunning 的話,會基於封包再加一層 Header

Host customer
Hostname customer.whatever.com <–跳板主機要能正確解析hostname才行,否則請填IP
User linuxuser
ForwardAgent yes
Port 22
ProxyCommand ssh user1@jump.linux.com -p 5566 nc %h %p

權重:static NAT > DNAT > SNAT

  • https://kb.juniper.net/library/CUSTOMERSERVICE/GLOBAL_JTAC/bk16110/new changed image.JPG
    其實這邊要講權重,其根本核心是轉換來源,轉換目的 能夠執行的點不同
    譬如說,作為一臺Router. 幫你轉發封包前,我可以幫你轉換目的,但是我不能幫你轉換來源。當封包確定要轉發,知道目標是誰後,這時候不能改目的,只能改來源
    前提是對方是基於 linux netfilter 的實作
    NAT 系列也是只有概念,但是實作標準不同

43/44 | 套路篇:網絡性能優化的幾個思路(上/下)- HWChiu

  • 網路性能指標:

    • Latency: determines how fast the contents within a pipe can be transferred from the client to the server and back
    • Throughput
    • PPS
    • CPS: C10K問題
    • TPS
  • 流量相關:

    Performance Tool
    BPF/PPS iperf3,pktgen
    Latency ping,hping3
    - -
    連接數 netstat,ss
  • 除錯工具:
    |

iperf2不建議使用,使用iperf3

網路性能指標

  • Latency
  • Throughput
  • PPS
  • CPS
  • TPS
  • Maximum concurrent connections

參考資料

會後問題:

  1. 原本想問 SO_REUSEPORT,是不是對一般 application 比較友善
  2. 想問一下iptable或是ebtable中間有一個Route Decision,他怎麼選擇要往上送localhost還是往其他chain送,這一段做了什麼magic funtion

FB

社群FB活動貼文 Round 4 #14

Select a repo