public

  • Download Gist
basic-load-balancing-httpd.conf
1 2 3 4 5 6 7 8 9
# Create a load balancer named "web-nodes"
<Proxy balancer://web-nodes>
# Add three load balancer members
BalancerMember http://www1.example.com
BalancerMember http://www2.example.com
BalancerMember http://www3.example.com
</Proxy>
# Send all requests to the "web-nodes" balancer
ProxyPass / balancer://web-nodes
create-your-own-sticky-sessions-httpd.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Set a cookie
Header add Set-Cookie "NODE=%{BALANCER_WORKER_ROUTE}e; path=/" \
env=BALANCER_ROUTE_CHANGED
# Create a load balancer named "web-nodes"
<Proxy balancer://web-nodes>
# Add three load balancer members
BalancerMember http://www1.example.com route=1
BalancerMember http://www2.example.com route=2
BalancerMember http://www3.example.com route=3
# Use the NODE cookie for sticky sessions
ProxySet stickysession=NODE
</Proxy>
# Send all requests to the "web-nodes" balancer
ProxyPass / balancer://web-nodes
route-based-on-http-method.httpd.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Enable mod_rewrite
RewriteEngine On
 
# Send POST, PUT, and DELETEs to "write" balancer
RewriteCond %{REQUEST_METHOD} ^(POST|PUT|DELETE)$
RewriteRule ^/(.*)$ balancer://write$1 [P]
 
# Send GET, HEAD, and OPTIONS to "read" balancer
RewriteCond %{REQUEST_METHOD} ^(GET|HEAD|OPTIONS)$
RewriteRule ^/(.*)$ balancer://read$1 [P]
 
# Modify HTTP response headers (e.g. Location)
ProxyPassReverse / balancer://write
ProxyPassReverse / balancer://read
sticky-sessions-in-php.httpd.conf
1 2 3 4 5 6 7 8 9 10 11
# Create a load balancer named "web-nodes"
<Proxy balancer://web-nodes>
# Add three load balancer members
BalancerMember http://www1.example.com
BalancerMember http://www2.example.com
BalancerMember http://www3.example.com
# Use the PHPSESSID for sticky sessions
ProxySet stickysession=PHPSESSID
</Proxy>
# Send all requests to the "web-nodes" balancer
ProxyPass / balancer://web-nodes
tsung.xml
XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
 
<!-- Client side setup -->
<clients>
<client host="test-a" weight="1" maxusers="10000" cpu="4" />
<client host="test-b" weight="1" maxusers="10000" cpu="4" />
</clients>
 
<!-- Server side setup -->
<servers>
<server host="www" port="80" type="tcp" />
</servers>
 
<!-- Load setup -->
<load>
<arrivalphase phase="1" duration="5" unit="minute">
<users arrivalrate="200" unit="second" />
</arrivalphase>
</load>
 
<!-- Session setup -->
<session name="default" probability="100" type="ts_http">
<thinktime value="1" random="true" />
<request>
<http method="GET" url="/" />
</request>
</session>
 
<!-- Monitoring setup -->
<monitoring>
<monitor host="www" type="munin" />
<monitor host="www1" type="munin" />
<monitor host="www2" type="munin" />
<monitor host="www3" type="munin" />
</monitoring>
 
</tsung>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.