Haproxy Load Balancing Algorithm Introduction:

Source: Internet
Author: User
Tags haproxy

First, Haproxy configuration introduction:

    • Configuration file:/usr/local/haproxy/etc/haproxy.cfg
    • Balance Roundrobin # Load Balancing algorithm configuration

Second, Haproxy load Balancing algorithm Introduction:

  • Balance Roundrobin # Polling, soft load balancing basically has this algorithm
  • Balance STATIC-RR # Based on weights, it is recommended to use
  • Balance Leastconn # Minimum number of connections processed first, recommended use
  • Balance Source # Based on the request Origin IP, it is recommended to use
  • Balance URI # Based on the requested URI
  • Balance Url_param # URL parameter according to request ' balance Url_param ' requires an URL parameter name
  • Balance HDR (name) # Lock every HTTP request based on the HTTP request header
  • Balance Rdp-cookie (name) # Locks and hashes each TCP request according to the cookie (name)


Third, the user session to maintain, share:

Due to the user request after Haproxy processing forwarding to different servers, may cause session sessions are not synchronized, if you want to achieve session sharing or retention, you can use the following 3 ways:

1, based on IP address:

    • Configuration: Balance Source

    • Implementation principle: Similar to Nginx ip_hash, the user IP after the Hash comparison judgment, the request forwarded to the back-end server.

2. Cookie-based identification:

    • Configuration: Cookie Session_cookie Insert Indirect nocache

    • Implementation principle: Insert (or add prefix) the server cookie ID of the backend defined by Haproxy into the cookie that is sent to the client from the Web server side.

3, based on session recognition:

    • Configuration: appsession jsessionid len 5h request-learn

    • Implementation principle: Haproxy The session and back-end server identities generated by the backend server are present in a table in Haproxy. This table is queried first when the client requests it.

Haproxy Load Balancing Algorithm Introduction:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.