Compilation of HAProxy for Windows and Its Application in CORS

Source: Internet
Author: User
Tags haproxy

Compilation of HAProxy for Windows and Its Application in CORS

1. Introduction to HAProxy

HAProxy provides high availability, Server Load balancer, and TCP and HTTP-based proxies. It is a free, fast, and reliable solution. HAProxy is especially suitable for websites with extremely high loads, which usually require session persistence or layer-7 processing. HAProxy runs on the current hardware and supports tens of thousands of concurrent connections. In addition, its running mode enables it to be easily and securely integrated into your current architecture, while protecting your web servers from being exposed to the network.

HAProxy implements an event-driven, single-process model that supports a large number of concurrent connections. Multi-process or multi-thread models are limited by memory, system schedulers, and ubiquitous lock restrictions, and are rarely able to process thousands of concurrent connections. Because the event-driven model implements all these tasks on a User-Space with better resource and time management, there is no such problem. The disadvantage of this model is that in multi-core systems, these programs are generally less scalable. This is why they must be optimized to make every CPU time slice (Cycle) do more work. Demonstrate the load balancing application model of HAProxy:

  

 

 

II. Application feasibility

Out of the many advantages of HAProxy, it is applied to CORS (Integrated System for continuous operation of satellite positioning service) O & M can effectively improve the current maximum load capacity, reduce the waste of hardware resources, and ensure the availability and stability of the system. Specifically, you can elaborate on the following aspects:

1. Functions of acting as a proxy server in the data stream distribution process of the Baseline Station Based on TCP proxy;

2. The Server Load balancer plays a role in user access and data broadcasting processes based on TCP proxy;

For CORS with a large number of users and high concurrency, HAProxy is used to map requests from external service ports to multiple applications with the same functions (such as IGate and TNC) in the internal network of the control center) HAProxy can maintain the affinity of tcp connections in multiple ways (IP, cookie, and session) to ensure the correctness of data interaction. Through a variety of Load Balancing algorithms, internal service programs share the overall service pressure. When a program goes down, HAProxy can automatically distribute the relevant tcp links to other service programs. HAProxy implements eight Load Balancing algorithms:

  • Roundrobin, indicating simple round robin
  • Static-rr, indicating that you can grant permissions based on the server performance.
  • Leastconn, indicating that the least connected person processes the request first
  • Source, indicating that the request source IP address
  • Uri, indicating that
  • Url_param, which indicates the request URl parameter 'balance url_param' requires an URL parameter name
  • Hdr (name) indicates that each HTTP request is locked Based on the HTTP request header.
  • Rdp-cookie (name) indicates that each TCP request is locked and hashed Based on the cookie (name ).

3. Implement the NAT Function of the internal network firewall based on the tcp proxy.

 

Iii. installation and configuration of HAProxy

The latest stable HAProxy version is http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.25.tar.gz.

1. Installation of HAProxy in Linux

  • Tar zcvf haproxy-1.4.25.tar.gz
  • Cd haproxy-1.4.25
  • Make TARGET = linux28 PREFIX =/usr/local/haprpxy
  • Make install PREFIX =/usr/local/haproxy
  • Cd/usr/local/haproxy
  • Vim haproxy. cfg: edit the configuration file.
  • /Usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy. cfg

2. Compilation and installation of HAProxy in Windows

  • Download the cygwin Installation tool, which is 64-bit: https://cygwin.com/setup-x86_64.exe. Run the program as follows:
  • Install gcc. If the status is Keep, the local machine is installed. If not installed, check the check box in the Bin column.
  • Install the make tool.
  • Copy the downloaded HAProxy source code package to: C: \ cygwin64 \ home and decompress it to this directory,
  • Use the Cywin64 Terminal command line tool to enter the HAProxy directory:
  • Make TARGET = cygwin
  • Make install is compiled and copied from haproxy.exe and cygwin1.dll for use.
  • The running mode is the same as that in Linux.

3. HAProxy Configuration File Parsing

######## Default configuration ############
Ults
Mode http # default mode {tcp | http | health}, tcp is Layer 4, http is Layer 7, health only returns OK
Retries 2 # If the connection fails twice, the server is considered unavailable. You can also set
Option redispatch # When the server corresponding to the serverId fails, it is forcibly directed to other healthy servers.
Option abortonclose # When the server load is high, the link for processing the queue for a long time is automatically terminated.
Maxconn 4096 # default maximum number of connections
Timeout connect 5000 ms # connection timeout
Timeout client 30000 ms # client timeout
Timeout server 30000 ms # server timeout
# Timeout check 2000 # = heartbeat detection timeout
Log 127.0.0.1 local0 err # [err warning info debug]


######## Statistics page configuration ########
Listen admin_stats
Bind 0.0.0.0: 1080 # listening port
Mode http # Layer-7 http mode
Option httplog # Use http log format
# Log 127.0.0.1 local0 err
Maxconn 10
Stats refresh 30 s # statistics page automatic refresh time
Stats uri/stats # url of the statistics page
Stats realm XingCloud \ Haproxy # text displayed in the password box on the statistics page
Stats auth admin: admin # user name and password settings on the statistics page
Stats hide-version # hide the HAProxy version on the statistics page


######## Test1 configuration #################
Listen test1
Bind 0.0.0.0: 90
Mode tcp
# Maxcon 4086
# Log 127.0.0.1 local0 debug
Server s1 10.18.138.201: 80
Server s2 10.18.102.190: 80
Server s3 10.18.102.189: 80
Server s4 10.18.102.188: 80
Server s5 10.18.102.187: 80
######## Frontend configuration ##############


######## Test2 configuration #################
Listen test2
Bind 0.0.0.0: 91
Mode tcp
# Maxcon 4086
# Log 127.0.0.1 local0 debug
Server s1 10.18.138.130: 80 weight 1
Server s2 10.18.138.201: 8080 weight 6
######## Frontend configuration ##############

4. instance Test

To test the running effect, we use the simplest configuration as a simple tcp Proxy:

########## Global configuration #########
Global
Daemon
Nbproc 1
Pidfile/var/run/haproxy. pid


######## Default configuration ############
Ults
Mode http # default mode {tcp | http | health}, tcp is Layer 4, http is Layer 7, health only returns OK
Retries 2 # If the connection fails twice, the server is considered unavailable. You can also set
Option redispatch # When the server corresponding to the serverId fails, it is forcibly directed to other healthy servers.
Option abortonclose # When the server load is high, the link for processing the queue for a long time is automatically terminated.
Maxconn 4096 # default maximum number of connections
Timeout connect 5000 ms # connection timeout
Timeout client 30000 ms # client timeout
Timeout server 30000 ms # server timeout
# Timeout check 2000 # = heartbeat detection timeout
Log 127.0.0.1 local0 err # [err warning info debug]


######## Statistics page configuration ########
Listen admin_stats
Bind 0.0.0.0: 1080 # listening port
Mode http # Layer-7 http mode
Option httplog # Use http log format
# Log 127.0.0.1 local0 err
Maxconn 10
Stats refresh 30 s # statistics page automatic refresh time
Stats uri/stats # url of the statistics page
Stats realm XingCloud \ Haproxy # text displayed in the password box on the statistics page
Stats auth admin: admin # user name and password settings on the statistics page
Stats hide-version # hide the HAProxy version on the statistics page


######## Test1 configuration #################
Listen test1
Bind 0.0.0.0: 81
Mode tcp
# Maxcon 4086
# Log 127.0.0.1 local0 debug
Server s1 192.168.1.200: 8000

Server s1 192.168.1.201: 8001

Server s1 192.168.1.202: 8002
######## Frontend configuration ##############


######## Test2 configuration #################
Listen test2
Bind 0.0.0.0: 91
Mode tcp
# Maxcon 4086
# Log 127.0.0.1 local0 debug
Server s1 192.168.1.100: 9000

Server s1 192.168.1.101: 9001

Server s1 192.168.1.102: 9002
######## Frontend configuration ##############

    

Haproxy + Keepalived build Weblogic high-availability server Load balancer Cluster

Keepalived + HAProxy configure high-availability Load Balancing

Haproxy + Keepalived + Apache configuration notes in CentOS 6.3

Haproxy + KeepAlived WEB Cluster on CentOS 6

Haproxy + Keepalived build high-availability Load Balancing

Configure an HTTP Load balancer using HAProxy

For details about HAproxy, click here
HAproxy: click here

This article permanently updates the link address:

Related Article

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.