`

HaProxy的负载均衡策略

阅读更多

roundrobin  Each server is used in turns, according to their weights.
                 This is the smoothest and fairest algorithm when the server's
                 processing time remains equally distributed. This algorithm
                 is dynamic, which means that server weights may be adjusted
                 on the fly for slow starts for instance. It is limited by
                 design to 4128 active servers per backend. Note that in some
                 large farms, when a server becomes up after having been down
                 for a very short time, it may sometimes take a few hundreds
                 requests for it to be re-integrated into the farm and start
                 receiving traffic. This is normal, though very rare. It is
                 indicated here in case you would have the chance to observe
                 it, so that you don't worry.

                 roundrobin:每个server根据权重依次被轮询,

这个算法是动态的,意味着
                 server的权重可以实时地被调整。对于每个haproxy的backend servers的数目
                 而言被限制在4128个活跃数目之内。


     static-rr   Each server is used in turns, according to their weights.
                 This algorithm is as similar to roundrobin except that it is
                 static, which means that changing a server's weight on the
                 fly will have no effect. On the other hand, it has no design
                 limitation on the number of servers, and when a server goes
                 up, it is always immediately reintroduced into the farm, once
                 the full map is recomputed. It also uses slightly less CPU to
                 run (around -1%).
                 静态roundrobin(static-rr):跟roundrobin类似,唯一的区别是不可以动态实时
                 server权重和backend 的server数目没有上限。

     leastconn   The server with the lowest number of connections receives the
                 connection. Round-robin is performed within groups of servers
                 of the same load to ensure that all servers will be used. Use
                 of this algorithm is recommended where very long sessions are
                 expected, such as LDAP, SQL, TSE, etc... but is not very well
                 suited for protocols using short sessions such as HTTP. This
                 algorithm is dynamic, which means that server weights may be
                 adjusted on the fly for slow starts for instance.
                 最小连接数目负载均衡策略(leastconn):round-robin适合于各个server负载相同的情况。
                 最小连接数目算法适合于长时间会话,如LDAP,SQL,TSE,但是并不适合于HTTP短连接的协议。

     source      The source IP address is hashed and divided by the total
                 weight of the running servers to designate which server will
                 receive the request. This ensures that the same client IP
                 address will always reach the same server as long as no
                 server goes down or up. If the hash result changes due to the
                 number of running servers changing, many clients will be
                 directed to a different server. This algorithm is generally
                 used in TCP mode where no cookie may be inserted. It may also
                 be used on the Internet to provide a best-effort stickiness
                 to clients which refuse session cookies. This algorithm is
                 static by default, which means that changing a server's
                 weight on the fly will have no effect, but this can be
                 changed using "hash-type".
                 源IP hash散列调度:将源ip地址进行hash,再根据hasn求模或者一致性hash定位到
                 hash表中的server上。相同的ip地址的请求被分发到同一个server上。但当server的数量变化时,
                 来自于同一client的请求可能会被分发到不同的server上。这个算法通常用在没有cookie的tcp模式下。

     uri         The left part of the URI (before the question mark) is hashed
                 and divided by the total weight of the running servers. The
                 result designates which server will receive the request. This
                 ensures that a same URI will always be directed to the same
                 server as long as no server goes up or down. This is used
                 with proxy caches and anti-virus proxies in order to maximize
                 the cache hit rate. Note that this algorithm may only be used
                 in an HTTP backend. This algorithm is static by default,
                 which means that changing a server's weight on the fly will
                 have no effect, but this can be changed using "hash-type".

                 This algorithm support two optional parameters "len" and
                 "depth", both followed by a positive integer number. These
                 options may be helpful when it is needed to balance servers
                 based on the beginning of the URI only. The "len" parameter
                 indicates that the algorithm should only consider that many
                 characters at the beginning of the URI to compute the hash.
                 Note that having "len" set to 1 rarely makes sense since most
                 URIs start with a leading "/".

                 The "depth" parameter indicates the maximum directory depth
                 to be used to compute the hash. One level is counted for each
                 slash in the request. If both parameters are specified, the
                 evaluation stops when either is reached.

     url_param   The URL parameter specified in argument will be looked up in
                 the query string of each HTTP GET request.

                 If the modifier "check_post" is used, then an HTTP POST
                 request entity will be searched for the parameter argument,
                 when it is not found in a query string after a question mark
                 ('?') in the URL. Optionally, specify a number of octets to
                 wait for before attempting to search the message body. If the
                 entity can not be searched, then round robin is used for each
                 request. For instance, if your clients always send the LB
                 parameter in the first 128 bytes, then specify that. The
                 default is 48. The entity data will not be scanned until the
                 required number of octets have arrived at the gateway, this
                 is the minimum of: (default/max_wait, Content-Length or first
                 chunk length). If Content-Length is missing or zero, it does
                 not need to wait for more data than the client promised to
                 send. When Content-Length is present and larger than
                 <max_wait>, then waiting is limited to <max_wait> and it is
                 assumed that this will be enough data to search for the
                 presence of the parameter. In the unlikely event that
                 Transfer-Encoding: chunked is used, only the first chunk is
                 scanned. Parameter values separated by a chunk boundary, may
                 be randomly balanced if at all.

                 If the parameter is found followed by an equal sign ('=') and
                 a value, then the value is hashed and divided by the total
                 weight of the running servers. The result designates which
                 server will receive the request.

                 This is used to track user identifiers in requests and ensure
                 that a same user ID will always be sent to the same server as
                 long as no server goes up or down. If no value is found or if
                 the parameter is not found, then a round robin algorithm is
                 applied. Note that this algorithm may only be used in an HTTP
                 backend. This algorithm is static by default, which means
                 that changing a server's weight on the fly will have no
                 effect, but this can be changed using "hash-type".

     hdr(name)   The HTTP header <name> will be looked up in each HTTP request.
                 Just as with the equivalent ACL 'hdr()' function, the header
                 name in parenthesis is not case sensitive. If the header is
                 absent or if it does not contain any value, the roundrobin
                 algorithm is applied instead.

                 An optional 'use_domain_only' parameter is available, for
                 reducing the hash algorithm to the main domain part with some
                 specific headers such as 'Host'. For instance, in the Host
                 value "haproxy.1wt.eu ", only "1wt" will be considered.

                 This algorithm is static by default, which means that
                 changing a server's weight on the fly will have no effect,
                 but this can be changed using "hash-type".

     rdp-cookie
     rdp-cookie(name)
                 The RDP cookie <name> (or "mstshash" if omitted) will be
                 looked up and hashed for each incoming TCP request. Just as
                 with the equivalent ACL 'req_rdp_cookie()' function, the name
                 is not case-sensitive. This mechanism is useful as a degraded
                 persistence mode, as it makes it possible to always send the
                 same user (or the same session ID) to the same server. If the
                 cookie is not found, the normal roundrobin algorithm is
                 used instead.

                 Note that for this to work, the frontend must ensure that an
                 RDP cookie is already present in the request buffer. For this
                 you must use 'tcp-request content accept' rule combined with
                 a 'req_rdp_cookie_cnt' ACL.

                 This algorithm is static by default, which means that
                 changing a server's weight on the fly will have no effect,
                 but this can be changed us
分享到:
评论

相关推荐

    负载均衡方案(LVS策略)

    实现负载均衡集群常见的软件实现方式:LVS和Haproxy 硬件实现方式:BigIp(F5), A10(IBM) ,Citrix(Netscaler) 考虑到复杂性以及成本因素,本方案使用LVS方式来实现负载均衡集群。

    实现负载均衡的Web服务器软件nginx-1.13.0

    实现负载均衡常用的Web服务器软件有Nginx、HAProxy、LVS、Apache,本资源是Nginx的负载均衡策略。 负载均衡的目的是为了解决单个节点压力过大,造成Web服务响应过慢,严重的情况下导致服务瘫痪,无法正常提供服务。

    nginx 代理问题,负载均衡问题

    Nginx负载均衡【`重点`】Nginx为我们默认提供了三种负载均衡的策略: ​ 轮询:将客户端发起的请求,平均的分配给每一台服务器。 ​ 权重:会将客户端的请求,根据服务器的权重值不同,分配不同的数量。 ​ ip_...

    CentOS基于nginx反向代理实现负载均衡的方法

    本文实例讲述了CentOS基于nginx反向代理实现负载均衡的方法。分享给大家供大家参考,具体如下: nginx做负载均衡的优点: 1、工作在网络的7层之上,可以针对http应用做一些分流的策略,比如针对域名、目录结构,它的...

    HAProxy——动静分离

    HAProxy——动静分离1. 在HAProxy端配置动静分离策略2. 在HAProxy端配置http3. 配置server2和server34.... 94 # balance roundrobin #负载均衡算法 95 # server web1 172.25.1.2:80 check 96 # serve

    nuster:基于HAProxy的高性能HTTP代理缓存服务器和RESTful NoSQL缓存服务器

    负载均衡 前端和后端均支持HTTPS HTTP压缩 HTTP重写和重定向 HTTP修复 HTTP2 监控方式 粘性 ACL和条件 内容切换 作为HTTP缓存服务器 nuster还可以用作HTTP代理缓存服务器(如Varnish或Nginx)来缓存动态和静态HTTP...

    RabbitMQ集群搭建指南:提升企业消息系统的效能与稳定性

    在当今信息技术迅速...此外,文档还提供了使用HAProxy实现负载均衡的方法,旨在提升整体架构的高可用性和性能。通过这些详尽的指导,IT专业人员可以有效搭建和管理RabbitMQ集群,确保企业消息系统的稳定和高效运行。

    基于SpringBoot+Vue的外卖网上点餐系统源码+项目说明.zip

    项目部署上采用Doker虚拟化技术部署在自己的阿里云上,整合合Nginx、Haproxy和keepalived,从数据库到后端、前端均采用多节点负载均衡策略部署。 整个项目用的都是目前主流的技术,覆盖前后端各个技术的基础,从...

    毕业设计早餐外卖微信小程序课程设计源代码

    配置三个节点的Nginx作为负载均衡器,第一个Nginx负责请求分发给后面两个Nginx,最后再把请求发送到不同的Tomcat容器 使用Redis Cluster作为早餐详细页面的第一级缓存 配置使用Ehcache作为页面的第二级缓存,并设置...

    趁早(quickearly)早餐外卖微信小程序-方便面的毕业设计.zip

    配置三个节点的Nginx作为负载均衡器,第一个Nginx负责请求分发给后面两个Nginx,最后再把请求发送到不同的Tomcat容器 使用Redis Cluster作为早餐详细页面的第一级缓存 配置使用Ehcache作为页面的第二级缓存,并设置...

    趁早(quickearly)B2C早餐外卖微信小程序

    配置三个节点的Nginx作为负载均衡器,第一个Nginx负责请求分发给后面两个Nginx,最后再把请求发送到不同的Tomcat容器 使用Redis Cluster作为早餐详细页面的第一级缓存 配置使用Ehcache作为页面的第二级缓存,并设置...

    MySQL大型分布式集群 龙果学院

    负载均衡概述以及环境准备 00:20:42分钟 | 第18节 搭建负载均衡-01 00:22:54分钟 | 第19节 搭建负载均衡-02 00:06:06分钟 | 第20节 启动haproxy的监控功能 00:14:52分钟 | 第21节 高可用以及环境准备 00:40:14...

    Consul:服务网络解决方案可跨任何云连接应用程序-开源

    自动化第三方负载均衡器(F5,NGINX,HAProxy)。 消除了对网络设备的手动配置。 利用基于意图的策略和服务网格资源之间的自动mTLS加密,可在任何环境中运行的安全服务。 Consul支持检测新服务的部署,对现有服务的...

Global site tag (gtag.js) - Google Analytics