使用 P4 交換器設計一個隨機最小連接負載均衡方法
A randomized least-connection first layer-4 load balancer using P4 switch
摘要
隨著資訊內容密集的增加,資訊處理已經超出單一伺服器所能負荷的程度,資料中心不只有一台伺服器,負載平衡成為現今資料中心服務的必要功能。第四層有狀態的負載平衡 (Layer-4 stateful load balancing) 是現代資料中心中的關鍵功能,這是影響雲服務效能的重要因素。第四層負載均衡是使用 IP 與 Port 的方式進行路由轉發,資料中心中的服務可通過在具有 Direct IP(DIP)位址的多台伺服器上運行來擴展,通過客戶端的 IP 地址和 Port,再加上負載均衡設備所採用的負載均衡演算法,最終確定選擇哪一台伺服器進行對應的服務。為了讓第四層負載均衡更有效率,Anata, DUET 相繼提出,然而軟體實現限制了負載平衡器的最大容量,且在軟體中處理封包還會導致嚴重的延遲問題,因此 Silkroad 在 p4 交換器實現了快速且便宜的負載均衡器,利用可編程交換器晶片 (ASIC) 的功能來在頻繁的 DIP 池更新下確保即使在頻繁更新 DIP Pool 的情況下,第4層有負載平衡器應保持每個連線一致性(Per-Connection Consistence, PCC)以獲得最佳性能。然而,上述的方法使用 Hash 演算法決策服務的伺服器,由於不同的 TCP 連線的持續時間是不同的,特別是在資料中心中,因此,使用基於 Hash 的負載平衡器,可能使得資料中心伺服器之間的負載極度不平衡。
於是,我們提出了隨機最小連接負載均衡方法,在 P4 交換器資料平面,我們可以允許負載平衡器通過 TCP 的 FIN 以及 SYN 來記錄每台伺服器上正在處理的連線的數量。並且使用兩次隨機演算法獲取 DIP 的方式,解決了在P4晶片資料層中為尋找最小連線伺服器,需要大量的記憶體存取 Counter 而造成延遲的問題,卻又可以適當的分配每個伺服器的負荷。在與傳統的 Round Robin 以及 Least Connection 實驗比較後,我們擁有比 Round Robin 更好的均衡效果並且比 Least Connection 更快的決策速度。
於是,我們提出了隨機最小連接負載均衡方法,在 P4 交換器資料平面,我們可以允許負載平衡器通過 TCP 的 FIN 以及 SYN 來記錄每台伺服器上正在處理的連線的數量。並且使用兩次隨機演算法獲取 DIP 的方式,解決了在P4晶片資料層中為尋找最小連線伺服器,需要大量的記憶體存取 Counter 而造成延遲的問題,卻又可以適當的分配每個伺服器的負荷。在與傳統的 Round Robin 以及 Least Connection 實驗比較後,我們擁有比 Round Robin 更好的均衡效果並且比 Least Connection 更快的決策速度。
With the intensive increase of information content, information processing has exceeded the load of a single server. There is more than one server in a data center. Load balancing has become a necessary function of today's data center services. Layer-4 stateful load balancing (Layer-4 stateful load balancing) is a key function in modern data centers, and it is an important factor affecting cloud service performance. The fourth layer of load balancing uses IP and Port for routing and forwarding. The services in the data center can be extended by running on multiple servers with Direct IP (DIP) addresses. Through the client's IP address and Port, Coupled with the load balancing algorithm used by the load balancing device, it is finally determined which server to choose for the corresponding service. In order to make the fourth layer of load balancing more efficient, Anata and DUET have successively proposed, but the software implementation limits the maximum capacity of the load balancer, and processing packets in the software will also cause serious delay problems. Therefore, Silkroad is implemented in the p4 switch In order to achieve a fast and cheap load balancer, the programmable switch chip (ASIC) function is used to ensure that even in the case of frequent DIP pool updates, the layer 4 load balancer should maintain each Per-Connection Consistence (PCC) for best performance. However, the above method uses the Hash algorithm to determine the server of the service. Since the duration of different TCP connections is different, especially in the data center, the use of a Hash-based load balancer may make the data center server The load between the devices is extremely unbalanced.
Therefore, we proposed a random minimum connection load balancing method. In the P4 switch data plane, we can allow the load balancer to record the number of connections being processed on each server through TCP FIN and SYN. In addition, the method of obtaining DIP by using two random algorithms solves the problem of delay caused by a large amount of memory access to the Counter in order to find the smallest connection server in the P4 chip data layer, but each can be allocated appropriately The load of the server. After comparing with the traditional Round Robin and Least Connection experiments, we have a better balance effect than Round Robin and faster decision-making speed than Least Connection.
Therefore, we proposed a random minimum connection load balancing method. In the P4 switch data plane, we can allow the load balancer to record the number of connections being processed on each server through TCP FIN and SYN. In addition, the method of obtaining DIP by using two random algorithms solves the problem of delay caused by a large amount of memory access to the Counter in order to find the smallest connection server in the P4 chip data layer, but each can be allocated appropriately The load of the server. After comparing with the traditional Round Robin and Least Connection experiments, we have a better balance effect than Round Robin and faster decision-making speed than Least Connection.