You are on page 1of 5

บทความนี้เหมาะสาหรับท่านเลือกใช ้ Algorithm สาหรับ Load balancer แบบต่างๆ หากรู ้

concept ก็จะรู ้ว่าแบบใดเหมาะกับงานของตนเอง

1. Load Balancing Algorithms: Least Connection


อัลกอริธม
ึ นี้ เป็ นแบบ default สาหรับ Load balancers ทีม ่ อ ่ ั่วไป เป็ น algorithm ทีใ่ ช ้เลือก
ี ยูท
server ทีม ี านวนการใช ้งาน หรือ Transaction น ้อยทีส
่ จ ่ ด
ุ ในขณะนัน ้

่ มต่อกับมัน โดยที่ server แต่ละตัวมี


ตัวอย่างเช่น load balancer ให ้บริการ server 4 ตัวทีเ่ ชือ
การเชือ่ มต่อเข ้ากับ load balancer ตัวนี้ และ server ต่างก็ม ี transaction ทีก่ าลังให ้บริการแก่
client กันอยู่ สมมติวา่ server แต่ละตัวมี transaction ทีก ่ าลังให ้บริการ client ดังนี้

Server 1 - 9 Active transactions


Server 2 - 4 Active transactions
Server 3 - 11 active transactions
Server 4 - 6 Active transactions

ตัว load balancers จะดาเนินการ monitoring transactions ของ server แต่ละตัวอย่าง


ต่อเนื่อง และมีการปรับปรุงหรือ อัพเดทบันทึกทีม ่ ก
ี ารเปลีย
่ นแปลง
จากตัวอย่างนี้ จะเห็นว่า Server 2 จะถูกเลือกให ้ทางานในขณะนัน ้ โดย load balancer
เนื่องจากว่า server 2 มีการทางานน ้อยทีส่ ด
ุ ในขณะนัน ้

least connection load balancing Algorithm จะกระจายงาน แบบเฉลีย ่ ไปยัง server ทุกตัว
โดยคานึงถึง ปริมาณของงาน หรือ ความมีธรุ ะยุง่ ของ server โดยความมีธรุ ะยุง่ ของ server แต่
ละตัวไม่เท่ากัน server ทีม
่ ธ
ี รุ ะยุง่ น ้อยทีส
่ ด ้ จะถูกเรียกใช ้งานโดย Load balancer
ุ ในขณะนัน
พูดง่ายๆคือ จะไม่ปล่อยให ้ server ตัวใดว่าง หลั่นล ้า แน่นอน

2. Load Balancing Algorithm: Round Robin Algorithm

Load Balancing Algorithm แบบ Round Robin เป็ นแบบทีม ่ ก


ี ารส่งงานไปยัง server แบบ
เรียงลาดับ โดยทีใ่ น Load balance จะมี รายชือ ่ ของ server แบบเรียงลาดับ อยูภ ่ ายใน มีการ
ส่งงานไปให ้ประมวลผล โดยเรียงจาก ตัวแรกไปจนถึงตัวสุดท ้าย เมือ ่ ถึงตัวสุดท ้าย ก็จะกลับมา
ทีต
่ ัวแรก เป็ นเช่นนี้ วนกันเป็ น Loop และเนื่องจาก เป็ นระบบทีก่ ระจายงานไปยัง server แบบ
เฉลีย ่ ด ้วยเหตุนี้ ปริมาณงานของ server แต่ละตัวจะมีขนาดเท่ากัน
Load Balancing แบบนี้ มีอยู่ 2 แบบ ได ้แก่

2.1 Weighted round robin

ภายใต ้การทางานของ weighted round robin load balancing algorithm. Server แต่ละตัว
จะได ้รับการจัดสรร น้ าหนัก (Weight) โดย Server แต่ละตัวมีคา่ Weight ไม่เท่ากัน ขึน ้ อยูก
่ บ

การจัด configure และขีดความสามารถในการประมวลต่อคาร ้องขอใช ้บริการทีม ่ าจากเครือ ่ ง
client
ตัวอย่างเช่น Server ตัวหนึง่ มีคา่ Weight เท่ากับ 5 ส่วนตัวอืน
่ มีคา่ Weight อยูท่ ี่ 2 และหาก
ตัว Load balancer ได ้รับการร ้องขอใช ้บริการ 5 ครัง้ มันจะส่งคาร ้องขอทัง้ 5 ของ Client ไปที่
Server ทีม่ ค
ี า่ Weight 5
แต่หาก Load balancer ได ้รับคาร ้องขอใช ้บริการเพียงแค่ 2 ก็จะส่งคาร ้องขอไปที่ Server ทีม ่ ี
ค่า Weight เท่ากับ 3 ทันที
2.2 Load Balancing Algorithm: Dynamic Round Robin

รูปแบบทีส ่ องนี้ Weight ของ Server ทุกตัวจะได ้รับการคานวณแบบ real time.


ด ้วยหลักการนี้เอง load balancer จะส่งคาร ้องขอใช ้บริการของ Client ไปยัง Server ตัวใด จะ
ใช ้ การคานวณและอัพเดท สถานะการทางานของ Server รวมทัง้ ปริมาณการร ้องขอเข ้ามา
แบบ Real Time ตลอดเวลา โดยข ้อมูล อัพเดทนี้ เป็ นข ้อมูลเกีย่ วกับปริมาณ Load และความ
อยูเ่ ฉยๆ หรือว่างของ Serve

2.3 Round Robin(RR) strict


Round Robin(RR) เข ้มงวดให ้วิธก ี ารแจกจ่ายทีก
่ ระชับยิง่ ขึน
้ ข ้ามเซิรฟ
์ เวอร์ภายในพูลกลุม ่
บริการ การเปิ ดใช ้งานตัวเลือก "เข ้มงวด" ภายในคุณลักษณะอัลกอริธม ึ RR ช่วยให ้สามารถล็อก
CPU ทัง้ หมดเพือ่ รับประกันว่าโหลดบาลานซ์จะกระจายอย่างสม่าเสมอทั่วทัง้ เซิรฟ ์ เวอร์
คุณลักษณะนี้เหมาะทีส ่ ด
ุ สาหรับสถานการณ์ CPU ทีม ี ริมาณการใช ้งานสูงหรือสูง ซึง่ รับประกัน
่ ป
การกระจายแบบ Round robin ในอัลกอริธม ึ round robin ทีเ่ ป็ นค่าเริม ่ ต ้น การเลือกเซิรฟ
์ เวอร์
อาจไม่สอดคล ้องกันเนื่องจากการแจกจ่ายอาจกระจายไปยังเซิรฟ ์ เวอร์อย่างไม่สม่าเสมอ

2.4 Fastest Response time


เร็วทีส่ ด
ุ (โหนด): ระบบส่งผ่านการเชือ ่ มต่อใหม่ตามการตอบสนองทีเ่ ร็วทีส
่ ดุ ของพูลทัง้ หมดที่
เซิรฟ์ เวอร์เป็ นสมาชิก เมธอดนี้อาจมีประโยชน์อย่างยิง่ ในสภาพแวดล ้อมทีโ่ หนดถูกกระจายไป
ทั่วเครือข่ายลอจิคัลต่างๆ

With that in mind here is an overview of each method...

• Round Robin: The system passes each new connection request to the next
server in line, eventually distributing connections evenly across the array of
machines being load balanced. This method works well in most
configurations, especially if the equipment that you are load balancing is
roughly equal in processing speed and memory.

• Ratio (member): The number of connections that each machine receives


over time is proportionate to a ratio weight you define for each machine
within the pool.

• Least Connections (member): The system passes a new connection to the


node that has the least number of current connections in the pool. This
method works best in environments where the servers or other equipment
you are load balancing have similar capabilities. This is a dynamic load
balancing method, distributing connections based on various aspects of real-
time server performance analysis, such as the current number of connections
per node or the fastest node response time.

• Observed (member): The system ranks nodes based on the number of


connections. Nodes that have a better balance of fewest connections receive
a greater proportion of the connections. This method differs from Least
Connections (member), in that the Least Connections method measures
connections only at the moment of load balancing, while the Observed
method tracks the number of Layer 4 connections to each node over time and
creates a ratio for load balancing. This dynamic load balancing method works
well in any environment, but may be particularly useful in environments
where node performance varies significantly.

• Predictive (member): Uses the ranking method used by the Observed


(member) methods, except that the system analyzes the trend of the ranking
over time, determining whether a node's performance is improving or
declining. The nodes in the pool with better performance rankings that are
currently improving, rather than declining, receive a higher proportion of the
connections. This dynamic load balancing method works well in any
environment.

• Ratio (node): The number of connections that each machine receives over
time is proportionate to a ratio weight you define for each machine across all
pools of which the server is a member.

• Least Connections (node): The system passes a new connection to the


node that has the least number of current connections out of all pools of
which a node is a member. This method works best in environments where
the servers or other equipment you are load balancing have similar
capabilities. This is a dynamic load balancing method, distributing connections
based on various aspects of real-time server performance analysis, such as
the number of current connections per node, or the fastest node response
time.

• Fastest (node): The system passes a new connection based on the fastest
response of all pools of which a server is a member. This method might be
particularly useful in environments where nodes are distributed across
different logical networks.

• Observed (node): The system ranks nodes based on the number of


connections. Nodes that have a better balance of fewest connections receive
a greater proportion of the connections. This method differs from Least
Connections (node), in that the Least Connections method measures
connections only at the moment of load balancing, while the Observed
method tracks the number of Layer 4 connections to each node over time and
creates a ratio for load balancing. This dynamic load balancing method works
well in any environment, but may be particularly useful in environments
where node performance varies significantly.
• Predictive (node): Uses the ranking method used by the Observed
(member) methods, except that the system analyzes the trend of the ranking
over time, determining whether a node's performance is improving or
declining. The nodes in the pool with better performance rankings that are
currently improving, rather than declining, receive a higher proportion of the
connections. This dynamic load balancing method works well in any
environment.

• Dynamic Ratio (node): This method is similar to Ratio (node) mode, except
that weights are based on continuous monitoring of the servers and are
therefore continually changing. This is a dynamic load balancing method,
distributing connections based on various aspects of real-time server
performance analysis, such as the number of current connections per node or
the fastest node response time.

• Fastest (application): Passes a new connection based on the fastest


response of all currently active nodes in a pool. This method might be
particularly useful in environments where nodes are distributed across
different logical networks.

• Least Sessions: The system passes a new connection to the node that
currently has the least number of persistent sessions. This method works best
in environments where the servers or other equipment you are load balancing
have similar capabilities. This is a dynamic load balancing method, distributing
connections based on various aspects of real-time server performance
analysis, such as the number of current sessions. Use of this load balancing
method requires that the virtual server reference a type of persistence profile
that tracks persistence connections.

• Dynamic Ratio (member): This method is similar to Ratio (node) mode,


except that weights are based on continuous monitoring of the servers and
are therefore continually changing. This is a dynamic load balancing method,
distributing connections based on various aspects of real-time server
performance analysis, such as the number of current connections per node or
the fastest node response time.

• Weighted Least Connections (member): The system uses the value you
specify in Connection Limit to establish a proportional algorithm for each pool
member. The system bases the load balancing decision on that proportion
and the number of current connections to that pool member. For example,
member_a has 20 connections and its connection limit is 100, so it is at 20
percent of capacity. Similarly, member_b has 20 connections and its
connection limit is 200, so it is at 10 percent of capacity. In this case, the
system select selects member_b. This algorithm requires all pool members to
have a non-zero connection limit specified.

• Weighted Least Connections (node): The system uses the value you
specify in the node's Connection Limit and the number of current connections
to a node to establish a proportional algorithm. This algorithm requires all
nodes used by pool members to have a non-zero connection limit specified.

• Ratio (session): The system selects the pool member according to the ratio
of the number of sessions each pool member has active. Note that pending
sessions count as active sessions.

• Ratio Least Connections (member): The system selects the pool member
according to the ratio of the number of connections each pool member has
active.

• Ratio Least Connections (node): The system selects the node according
to the ratio of the number of connections each node has active.

You might also like