In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article analyzes "what are the common algorithms for load balancing in programming languages?" The content is detailed and easy to understand. Friends who are interested in "what are the common algorithms of load balancing in programming language" can follow the editor's train of thought to read it slowly and deeply. I hope it will be helpful to everyone after reading. Let's learn more about "what are the common algorithms for load balancing in programming languages" with the editor.
Cold standby and hot standby
Cold backup (cool standby), which is equipped with standby equipment that does not normally operate, and is replaced by standby equipment when the running equipment fails.
Hot backup (hot standby) refers to running the standby device while the device is running, which can automatically replace the standby device when the running device fails.
Fail-over and fail-back
Fail-over, in the spare structure, the process of stopping running a device and using a standby device for work is called replacement, which is called fail-over or switch-over in English.
Fail-back, which returns to the original running equipment again after replacement, that is, the process of switching from the running standby device to the original running device, is called fallback, which is called fail-back or switch-back.
Redundancy Typ
1. Active / standby mode (Active-Standby)
Prepare two routers, one of which is an active device (active) for normal operation, which can also be called a master device (master) or a primary device (primary). The other is used as a standby device (standby) to be replaced in the event of a failure, which can also be referred to as a standby (backup), a slave (slave), and a necessary equipment (secondary). Active and standby devices must share setup information about the device.
two。 Dual active mode (Active-Active)
Prepare two routers, one as the primary device (primary) and the other as the secondary device (secondary), to form a redundant structure. This method can achieve the purpose of load balancing by using the DNS with the load balancing device or setting the routing information on the client side.
3. Cluster mode (Cluster)
In the active / standby mode or dual-active mode, more than three sets of hardware are used to form a redundant structure.
What is load balancing?
Load balancer, whose English name is Load Balance, means that multiple servers form a set of servers in a symmetrical manner. Each server has an equivalent status and can provide services independently without the assistance of other servers. Through some kind of load sharing technology, the requests sent from the outside are evenly distributed to a server in the symmetrical structure, and the server that receives the request responds to the client's request independently. Load balancer can evenly distribute customer requests to the server array, so as to provide rapid access to important data and solve a large number of concurrent access service problems. This cluster technology can achieve performance close to that of mainframes with the least investment.
Load balancing algorithms are widely used in many places, whether in service governance or in distributed caching. This paper mainly introduces several common load balancing algorithms.
1. Polling method
The polling method, which is easy to understand, allocates requests to the server in turn. It treats each back-end server evenly, regardless of the number of connections and load of the server. The following code demonstrates this algorithm.
Public class BalanceServer {public static List servers = Arrays.asList ("192.168.0.1", "192.168.0.2", "192.168.0.3", "192.168.0.4", "192.168.0.5"); public static int pos = 0; public static String getServer () {String server = null; if (pos > = servers.size ()) {pos = 0;} server = servers.get (pos); pos++; return server } public static void main (String [] args) {for (int item0 = servers.size ()) {pos = 0;} server = servers.get (pos); pos++; return server;} public static void main (String [] args) {for (int ibido)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.