Discover load balancer sticky session, include the articles, news, trends, analysis and practical advice about load balancer sticky session on alibabacloud.com
Proxy has a concept of session adhesion, it will be all the files about the cookie on the Apache server, the other operations will read such a file.Apache Reverse Proxy Setup methodOpen the Conf folder for the Apache installation directory (Linux in/etc/httpd/conf or/usr/local/apache/conf)Open httpd.confPutLoadModule Proxy_module modules/mod_proxy.soLoadModule Proxy_http_module modules/mod_proxy_http.soRemove the previous commentAt the end of httpd.c
A brief introduction to the principle1.HAProxyHaproxy provides high availability, load balancing, and proxies based on TCP and HTTP applications, supporting virtual hosting, which is a free, fast, and reliable solution. Haproxy is especially useful for Web sites that are heavily loaded, and often require session-hold or seven-tier processing. Haproxy runs on today's hardware and can support tens of thousand
A brief introduction to the principle1.HAProxyHaproxy provides high availability, load balancing, and proxies based on TCP and HTTP applications, supporting virtual hosting, which is a free, fast, and reliable solution. Haproxy is especially useful for Web sites that are heavily loaded, and often require session-hold or seven-tier processing. Haproxy runs on today's hardware and can support tens of thousand
;
Proxy_next_upstream Error timeout Invalid_header http_500 http_502 http_503 http_504;
Proxy_max_temp_file_size 0;
Proxy_connect_timeout 90;
Proxy_send_timeout 90;
Proxy_read_timeout 90;
Proxy_buffer_size 4k;
Proxy_buffers 4 32k;
Proxy_busy_buffers_size 64k;
Proxy_temp_file_write_size 64k;
}
}
There are several ways Nginx does load balancing:1. RR (default) Each request is assigned to a different back-end server in chronol
Issue background:Client-----------LB----------RS (single) Access OKClient-----------LB----------RS (more than one) Access exceptionSpecific phenomena:401 Authentication failed for multiple RS accessCause: The session of the RS is stored locally and the two RS are not sharedSolution: Temporarily open the session to keep it good, long-term resolution needs to share session.Request Connection database authenti
8009, changed to 20009. The redirectport is changed to 20043.★Comment out the original: ★Open the comment of the cluster element, and change the listening port tcplistenport of the worker Er element to 20011.Start Tomcat 2 and you will see the following prompt:In limit at1:14:25:46 org. Apache. Catalina. Cluster. tcp. simpletcpcluster memberaddedInformation: Replication member added: org. Apache. Catalina. Cluster. MCAST. mcastmember [TCP: // 192.168.1.192: 20011, Catalina, 192.168.1.192, 20011
Failure Phenomena:The server port under the load Balancer VIP can be telnet, but the URL corresponding to the port cannot be Opened.Workaround:Use forceproxy, and modify the Server's underlying configuration to resolve the failureTwo modes of dbind:Enable: corresponds to the Alteon traditional 7-tier engine, after three handshake with the client, forwards the data to the Server.Forceproxy: the corresponding
Today, the teacher talked about the server architecture. Although simple, there are still some difficulties. We need to expand the architecture on this basis.
There is data synchronization during Server Load balancer. Baidu later saw the previous generation share:
Inotify + Rsync is used to implement batch synchronization and batch update of Linux Files in batches. This should be a frequent task for O M pe
About haproxy
Provides high availability, Server Load balancer, and proxy Based on TCP and HTTP applications, and supports Virtual Hosts. 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 suppor
configuration file is divided into six main areas:Main (Global Settings), events (nginx working mode), HTTP (HTTP settings),Sever (Host settings), location (URL match), Upstream (Load balancer server settings). Main module
Below a main area, he is a global setting:
User nobody nobody; Worker_processes 2; Error_log/usr/local/var/log/nginx/error.log notice; Pid/usr/local/var/run/nginx/nginx.pid; Worker_rlimi
The front end uses httpd as the reverse load balancer to the back-end Tomcat host: Tomcat can use memcached as the session server to save the session:Experimental environment: Physical machine Win7, virtual machine centos7node1:172.18.11.111 Tomcatanode2:172.18.11.112 TOMCATBNODE3:172.18.11.113 Scheduler httpd650) this.width=650; "src=" Http://s1.51cto.com/wyfs02
check whether port 8080 and port 4001 are enabled for each Tomcat server. Use netstat-An to view the link information. TCP 0 0 172.23.254.2: 43320 172.23.254.3: 4001 established TCP 0 0 172.23.254.2: 46544 172.23.254.3: 4001 time_wait TCP 0 0 172.23.254.2: 40118 172.23.254.3: 4001 established TCP 0 0 172.23.254.2: 4001 172.23.254.3: 48804 established TCP 0 0 172.23.254.2: 4001 172.23.254.3: 34254 established If the connection is established on port 4001 of both machines, the cluster conf
the 4001 ports of the two machines are connected separately, the cluster configuration is successful and session replication is possible.Problems that may exist1, Session replication problemBefore using Apache for load balancing, is the choice of the session sticky mode, so
Here are the configuration for Apache load balancer and reverse proxyChoose Apache HTTP Server as the front-end load server, the backend select two tomcat for the cluster, this choice is configured in session Sticky (sticky
Loading the relevant Apache modules
To release annotations in the configuration file httpd.conf #加载mod_proxyLoadModule proxy_module modules/mod_proxy.soloadmodule proxy_ajp_module modules/mod_proxy_ Ajp.soloadmodule proxy_balancer_module modules/mod_proxy_balancer.soloadmodule proxy_connect_module modules/mod_ Proxy_connect.soloadmodule proxy_ftp_module modules/mod_proxy_ftp.soloadmodule proxy_http_module modules/mod_proxy _http.soBecause these modules are automatically available
Apache is based on MOD_PROXY_AJP, mod_proxy_http, mod_jk three kinds of schemes to implement agent, load balancing, session binding and Tomcat session cluster1, Nginx, Haproxy, Apache (MOD_PROXY_AJP, Mod_proxy_http, MOD_JK) anti-user request to Tomcat;2, Nginx, Haproxy, Apache (MOD_PROXY_AJP, mod_proxy_http, mod_jk) load
"Stay active on the server". Each session variable is set on the network server and remains in the
In local memory. So what if you use load balancing on a web-wide scale? (For an introduction to load balancing, see
MSDN article ' ASP and Web session Management '). For real load
Windows Azure Load Balancer defaults to 5-tuple hash: Source address, source port, destination address, destination port, protocol. That is, only session packets with exactly the same five tuples will be forwarded to the same back-end server. Obviously, for the vast majority of users with NAT Internet access, the 5-tuple does not have a
/mod_proxy_balancer.html
Restart Apache, test.
You can see that the second image is a load-balanced cookie to access the server to achieve session retention.
Ps:
When you open the page, prompt the server 500 error to view the log:
[Warn] Proxy:no protocol handler is valid for the url/public/js/jquery.js. If you are are using a DSO version of Mod_proxy, make sure the proxy submodules are included in
Check some of the information, read some other people wrote the document, summarized as follows, to realize the sharing of Nginx sessionPHP server has more than one, with nginx load balancer, so that the same IP access to the same page will be assigned to different servers, if the session is not synchronized, there will be many problems, such as the most common l
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.