In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Balance is used in the backend section when using haproxy to indicate how to implement the scheduling of the back-end server.
Balance: indicates the scheduling algorithm
Dynamic algorithm: weights can be adjusted dynamically
Static algorithm: adjusting the weight will not take effect in real time, it can only take effect by restarting.
The algorithms of balance are: roundrobin,static-rr,leastconn,source,uri,uri_param,hdr and so on.
Roundrobin algorithm:
Polling, polling based on weight, this algorithm is dynamic, and each back-end server can only accept up to 4128 connections
It is required that the backend cannot have state, session, etc., and can only be static pages.
When the backend has dynamic information such as session, it works best when used in combination with cookie.
Static-rr algorithm:
Static roundrobin does not support dynamic adjustment; static algorithm, there is no upper limit on the number of backend hosts supported.
Leastconn algorithm:
New connection requests are dispatched to the back-end server with the minimum number of connections according to the load of the back-end host
This method is recommended in the scenario of long connection session. It is not suitable for http, dynamic algorithm.
Source algorithm:
Hash the requested source address; divide the total weights of the back-end servers and send them to a matching server. This method allows requests from the same IP to be sent to the same server. However, when the total weight of the server changes, such as a server down or a new server is added, many client requests may be dispatched to servers that are different from previous requests. TCP-based protocol that is commonly used for load balancing without cookie functionality; it defaults to static, but this feature can also be modified using hash-type
Hash-type:
Map-based: module-taking method (module-removing method); (static, default)
Consistent: consistent hash; (dynamic so that later need to specify: hash-type consistent)
Uri algorithm:
Hash the left half of the URI (the part before the "question mark" mark) or the entire URI and distribute it to a matching server after dividing the total weights of the server; this allows requests for the same URI to always be sent to a specific server unless the total weight of the server changes; this algorithm is often used for proxy caching or antivirus agents to improve cache hit rates
Example: http://www.baidu.com/abc/query?item=123 # the part marked in red is the part of uri
Hash-type:
Map-based: module-taking method (module-removing method); (static, default)
Consistent: consistent hash; (dynamic so that later need to specify: hash-type consistent)
Note: when using uri, after visiting a backend page, all subsequent requests for this page are sent to this server
When you have not visited a backend page, use the roundrobin algorithm, randomly pick a response, and then all the requests for this page are sent to this host, this algorithm is very effective when the backend cache!
Roundrobin algorithm combined with the usage of cookie:
The function of cookie is to implement session sticky in a basic browser.
How to use cookie: cookie [rewrite | insert | prefix] [indirect] [nocache]
[rewrite | insert | prefix]: how to add cookie
Rewrite: replace the original cookie
Insert: insert # after the original cookie. This is the most common way.
Prefix: insert in front of the original cookie
The methods commonly used by cookie:
Cookie SERVERID insert indirect nocache
Note:
A.SERVERID, which is randomly specified by yourself, is SERVERID=websrv1,SERVERID=websrv2;insert in the following example: it is inserted after the original cookie.
b. Do not bind according to the source IP, but bind according to different clients. I feel better than source, because source sends the same IP to the same back-end server. According to different client bindings, users of the same public network IP can send requests to different backends.
C.roundrobin algorithm, combined with cookie, can be tried; this method makes up for the disadvantage that roundrobin does not maintain the session.
Examples of usage:
Balance roundrobin
Cookie SERVERID insert indirect
Server web1 192.168.0.100 check weight 1 cookie websrv1
Server web2 192.168.0.101 check weight 3 cookie websrv2
Note: websrv1: the cookie identifier that is proprietary to web1 and can be seen in the cookie of the client browser
Websrv2: the cookie identifier that is proprietary to web2 and can be seen in the cookie of the client browser
The most commonly used algorithms are:
Roundrobin
Source
Uri
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.