Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.
-
Upload
isaac-richardson -
Category
Documents
-
view
243 -
download
5
Transcript of Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.
![Page 1: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/1.jpg)
mod_proxy
Clustering and load balancingwith Apache 2.2 mod_proxy
![Page 2: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/2.jpg)
Agenda
Proxy architecture Proxy protocols Load balancing Dynamic runtime management
![Page 3: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/3.jpg)
Proxy architecture
Worker conceptForward workerReverse workerNamed reverse workersBalancer workers
![Page 4: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/4.jpg)
Forward worker
Standard mod_proxy forward proxying Enabled globally or per vhost withProxyRequests On
Fixed connection pool sizeSingle on prefork_mpmThreadsPerChild on worker_mpm
![Page 5: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/5.jpg)
Reverse worker
Single global worker Enabled by default Fixed connection pool size
Single on prefork_mpmThreadsPerChild on worker_mpm
Used for unknown reverse proxy requestsfrom mod_rewrite
![Page 6: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/6.jpg)
Named reverse workers
Created for each uniquehostname:port ProxyPass directive
Created for each uniquehostname:port BalancerMember directive
Dynamic connection pool size forthreaded mpm’s.Defaults to ThreadsPerChild
![Page 7: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/7.jpg)
Balancer workers
Virtual worker Contain 1…n real protocol workers
LoadModule balancer_module modules/mod_proxy_balancer.so
<Proxy balancer://cluster> BalancerMember http://remote:port …</Proxy>
![Page 8: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/8.jpg)
Proxy architecture
Shared memory runtime data
Parent process
Listener Socket
Worker #1
Worker #2
Worker #n
Child process
Worker #1
Worker #2
Worker #n
Child process
Worker #1• status• elected• read• transferred• …
Worker #2
Worker #n
Scoreboard
User
![Page 9: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/9.jpg)
Proxy architecture Session affinity
ajp://host1:8009 route=ATomcat/host1jvmRoute=“A”
AJP
13
AJP
/1.3
ajp://host1:8009 route=BTomcat/host2jvmRoute=“B”
AJP
13
AJP
/1.3
<Proxy balancer://cluster> BalancerMember ajp://host1:8009 route=A BalancerMember ajp://host2:8009 route=B</Proxy>
JSESSIONID=XXX.A
![Page 10: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/10.jpg)
Proxy architecture
Sticky sessions
![Page 11: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/11.jpg)
Proxy Protocols
http/https connect ftp ajp balancer
![Page 12: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/12.jpg)
AJP Protocol
Apache Java Protocol Current version 1.3 (AJP13) Binary http protocol No need to marshal/unmarshal http request Reusable connections Supported by most Java app servers
Tomcat Jetty
http://jakarta.apache.org/tomcat/connectors-doc/common/ajpv13a.html
![Page 13: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/13.jpg)
AJP 1.4 Protocol
Next generation AJP protocolEncryptionCompressionFeedback from remote node
Too busy Going to shutdown Change dynamic config Update load balancer factor
Q4 2005
![Page 14: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/14.jpg)
Load Balancing
mod_proxy_balancer.so Protocol independent Multiple strategy
RequestTraffic
Session affinity Failover
![Page 15: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/15.jpg)
Load Balancing
BalancerMemberProtocol worker to remoteMultiple protocolsSession affinity (Sticky sessions)Preferred failover node
![Page 16: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/16.jpg)
Balancer Parameters
<Proxy balancer://cluster param=value .. >
</Proxy>
..
ProxySet balancer://cluster param=value
![Page 17: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/17.jpg)
stickysession
Check for session mark at the end of session identifier.
Configurable session identifier namestickysession=JSESSIONIDstickysession=PHPSESSIONID
JSESSIONID=827BFE8CB4E01BCEAE41D02042485F05.SESSIONMARK
![Page 18: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/18.jpg)
nofailover
Failover by defaultnofailover=On
Disables failover
Bound to remote until expiredEnables removing nodes from cluster
![Page 19: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/19.jpg)
lbmethod
Defines balancer strategylbmethod=Request
Default strategy Counts number of requests to remote
lbmethod=Traffic Default strategy Counts number of bytes read/transferred
![Page 20: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/20.jpg)
timeout
Maximum time to wait for a free connection in secondsAll workers are in error stateAll workers are busyOnly for threaded mpm’s.Limiting the number of opened connection to
remote
![Page 21: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/21.jpg)
maxattempts
Maximum number of failover attemptsDefaults to number of membersmaxattempts=1
No failover
![Page 22: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/22.jpg)
Worker Parameters
ProxyPass http://host param=value ..
BalancerMember ajp://host param=value ..
..
ProxySet http://cluster param=value
![Page 23: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/23.jpg)
loadfactor
loadfactor=1Normalized load factorUsed with BalancerMember loadfactor=1 loadfactor=2Same as: loadfactor=3 loadfactor=6
![Page 24: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/24.jpg)
retry
Number of seconds to retry the worker Default is 60 seconds.
![Page 25: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/25.jpg)
Connection pool tuning
min Initial number of connections to remote
max Maximum number of connections to remote
smax connections to remote that will not be destroyed
ttl destroy all the connections that exceed the smax
![Page 26: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/26.jpg)
keepalive
keepalive=OnSend SO_KEEPALIVEUseful if remote is behind firewall
![Page 27: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/27.jpg)
timeout
Connection timeout in secondsDefaults to ServerTimeout
![Page 28: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/28.jpg)
route
Session route nameMatch with jvmRoute in Tomcat
route=someName
..
<Engine .. jvmRoute=“someName” />
![Page 29: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/29.jpg)
redirect
Preferred failover If session route worker is in error state
BalancerMember .. route=A redirect=B
..
BalancerMember .. route=B
![Page 30: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/30.jpg)
Dynamic runtime management
Runtime statusHook for status_module
Balancer managerWeb page management
![Page 31: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/31.jpg)
Runtime status
LoadModule status_module ....<Location /server-status>
SetHandler server-statusOrder deny,allowDeny from allAllow from localhost
</Location>..
ProxyStatus On
![Page 32: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/32.jpg)
Runtimestatus
![Page 33: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/33.jpg)
Balancer Manager
Dynamic management of balancer Management of balancer members
![Page 34: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/34.jpg)
Balancer Manager
LoadModule proxy_balancer_module ..
..
<Location /manager>
SetHandler balancer-manager
Order deny,allow
Deny from all
Allow from localhost
</Location>
![Page 35: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/35.jpg)
![Page 36: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/36.jpg)
![Page 37: Mod_proxy Clustering and load balancing with Apache 2.2 mod_proxy.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649cf05503460f949bf3e7/html5/thumbnails/37.jpg)
Q&A