Although we see that the official documentation of HAProxy does have a lot of configuration content, in fact, we use it in the online environment. Only a few of them are enough. This is why HAPROxy is simple. The corresponding configuration file of HAProxy is as follows. Show:
global log 127.0.0.1 local0 maxconn 4096 chroot /usr/local/haproxy uid 99 gid 99 daemon nbproc 1 pidfile /usr/local/haproxy/logs/haproxy.pid debug defaults log 127.0.0.1 local3 Mode http option httplog option httpclose option dontlognull option forwardfor option redispatch retries 2 maxconn 2000 balance source stats uri /haproxy-stats contimeout 5000 clitimeout 50000 srvtimeout 50000 listen 1paituan_proxy 203.93.236.149:80 option httpchk HEAD /index.jsp HTTP/1.0 server web1 203.93 .236.147:80 cookie app1inst1 check inter 2000 rise 2 fall 1 server web2 203.93.236.146:80 cookie app1inst2 check inter 2000 rise 2 fall 1
plus log support as follows:
#vim /etc/syslog.conf Add: local3.* /var/log/haproxy.log local0.* /var/log/haproxy.log #vim /Etc/sysconfig/syslog Modifications: SYSLOGD_OPTIONS="-r -m 0" service syslog restart
There are several places to note here:
First, HAProyx uses the balance source mechanism. It is the same as the persistence of LVS and the ip_hash of Nginx. It is a real web server that allows the client to access the backend at all times;
2.203.93.236.149 is the VIP generated by my website through Keepalived. Address;
Third, option httpchk HEAD /index.jsp HTTP/1.0 is the web page approaching, if HAProxy does not detect the root directory of the Web without index.jsp, it will generate 503 error.
HAProxy+keepalived/Heartbeat is the second solution of my website, because I just started the LVS+Keepalived high-availability architecture on the website. Later, when a few friends said that using mobile phones to test, the forwarding is very slow, sometimes not playing. Open, and even some computers are like this. I tried the following: I used Nginx+Keepalived and found that the forwarding speed is really much faster. There is no such problem on the mobile phone. Because of Nginx+Keepalived customers in Dongguan. It has been deployed very successfully, so I later considered designing this website as HAProyx+Keepalived.
The algorithm of HAProxy has the following eight kinds:
First, roundrobin, which means simple polling, this is not much to say, this is basically supported by load balancing;
Second, static-rr, indicating that according to the weight, it is recommended to pay attention;
Third, leastconn, indicating that the least connector is processed first, it is recommended to pay attention;
Fourth, source, according to the request source IP, suggest Concern;
Five, uri, indicating the URI according to the request;
Six, url_param, indicating the URl parameter according to the request 'balance url_param' requires an URL parameter name
, hdr (name), means to lock each HTTP request according to the HTTP request header;
eight, rdp-cookie (name), means to lock and hash each TCP request according to the cookie (name).
In fact, these algorithms have their own usages. We should use roundrobin, source and lestconn in general. You can focus on the following. Here I used HAProxy+Keepalived without considering the HA of the HAProxy process level. First, because Taobao is also using it as a load balancer, the stability certainly does not need to be skeptical; secondly, it was found to be quite stable during the test, killing The HAProxy process must also use kill -9, so it didn't waste time on it; it did consider using HAProxy+Keepalived to do the dual-master architecture during the test, and later found that it was not too good to maintain.
One thing to remind everyone is that HAProxy supports virtual hosting. I have seen some friends say that it is not supported. This is actually very good. We have a 1+1 architecture. Nginx or Aapceh's web server may verify this statement; in addition, after comparing with Nginx's regularity, we also found that HAProxy's regular processing power is not as strong and flexible as Nginx, we can also take a compromise here. Solution, the latter web server we use Nginx to do, if it is a jsp application, you can use Nginx+tomat, if you are running PHP, you can use Nginx+FastCGI (PHP5).
Today we are here to communicate on the speed of the website. Improving the speed
In order to improve the performance of the server, many network administrators ha
<IfModule mpm_prefork_module> LIS)(?X<]? StartServers 5 6DM$g=/? MinSpareServers 5 -9%:i?lX
1. start --- & gt; control panel --- & gt; management tools --- & gt; Internet In
After reinstalling the domain and server, users can also see the mail?
IIS URL Rewriting Rewrite Filter Setting Method Introduction
Server Management Maintenance: Clear DNS Cache
Wget operation under CentOS can not resolve (resolution) problem solution
The difference between URL forwarding "hidden" and "not hidden"
Form a high-speed and secure file server
Ubuntu Linux installation PHP development environment Zend Studio 5.5.1
Open the file sharing manager with 2003, 03
Teach you three tricks, and the electrical fire in the computer room said no!
How to change the text on the browser title under WinXP
Win7 system after the DNF screenshot can not find the intercepted picture how to solve the
How to create a system restore point in win10?
Where is the Win10 computer drawing tool? How to open the computer drawing tool in Win10
How to cancel the keyboard prompt sound in Windows8 system
Enhancing Win7 multi-core functionality is not an empty talk
Win8.1Update1 Announced Completion Key Information Summary
How does win10 close the windows security alert window in the lower right corner?