Show Table of Contents
5.5. backend 設定
backend 這設定會指定真實伺服器的 IP 位址,以及負載平衡程式的排程演算法。以下範例顯示了典型的 backend 一節:
backend app balance roundrobin server app1 192.168.1.1:80 check server app2 192.168.1.2:80 check server app3 192.168.1.3:80 check inter 2s rise 4 fall 3 server app4 192.168.1.4:80 backup
後端伺服器名為
app。balance 會指定負載平衡程式的排程演算法,此範例中使用的乃循環法(roundrobin),但可以是任何 HAProxy 所支援的排程程式。欲知如何在 HAProxy 中配置排程程式,請參閱〈節 5.1, “HAProxy 排程演算法則”〉。
server 行指定了後端可以使用的伺服器。app1 到 app4 是內部指定到每台真實伺服器的名稱。位址是指定的 IP 位址。IP 位址冒號後面的是在伺服器上發生連線的連接埠號。check 選項標誌著定期「健康檢查」的伺服器,以確保伺服器的可用性,得以收送資料並服務 session 的請求。伺服器 app3 也配置了健康檢查的間隔,時間為 2 秒(inter 2s)、app3 用來決定伺服器是否健康的檢查次數(rise 4)、以及伺服器直至認定為失敗的重試次數(fall 3)。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.