You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by kh...@oreillyauto.com on 2012/05/31 17:49:34 UTC

[users@httpd] Balancer logic on a per-context basis

Hello,

I have a couple apache http servers (v2.2) proxying requests to a handful
of tomcat servers (6.x) serving applications in individual contexts.  I
have a ProxyPass line for each context in my config.  I'm utilizing the
proxy balancer and its working well; if I kill "tomcat1", apache will quit
sending requests to it as expected.  However, if I stop a context (to
simulate a crashed app) and leave tomcat running, apache seems to consider
the balancer member alive.  Obviously, this results in "unavailable"
responses from Tomcat to the end user.

I realize there are multiple technologies at work here (apache balancer,
AJP, and tomcat).  Is it possible to configure apache to check each context
listed with a ProxyPass directive for availability, and execute logic based
on that (e.g. remove the balancer_member, or select another balancer_member
for requests to that ProxyPass item)?

Based on my reading of the documentation and archives, it appears the
balancer is concerned with connectivity to the http/ajp connector of the
back-end server, which makes sense.  I understand HTTP isn't designed to do
what I'm asking, but I'm hoping there is some special functionality in AJP
that could allow the aforementioned to be possible.

Thanks for any input.


--- httpd Configuration Snippet ---
<Proxy balancer://some-balancer>
  BalancerMember ajp://tntest-app-a-1:8009 loadfactor=1 route=tomcat1
  BalancerMember ajp://tntest-app-a-2:8009 loadfactor=1 route=tomcat2
  ProxySet lbmethod=byrequests stickysession=JSESSIONID|jsessionid
scolonpathdelim=On
</Proxy>

ProxyPass /testApp  balancer://some-balancer/testApp
ProxyPass /anotherApp  balancer://some-balancer/anotherApp


--- System Info ---
OS: Ubuntu 10.04 LTS
Apache httpd: 2.2.14 (Ubuntu)
Tomcat: 6.0.24
AJP Protocol version 1.3

Kyle Harper

This communication and any attachments are confidential, protected by Communications Privacy Act 18 USCS � 2510, solely for the use of the intended recipient, and may contain legally privileged material. If you are not the intended recipient, please return or destroy it immediately. Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Balancer logic on a per-context basis

Posted by Daniel Ruggeri <DR...@primary.net>.
On 5/31/2012 1:40 PM, kharper2@oreillyauto.com wrote:
> I am using AJP exclusively to the balancer-members.  Forgive my
> ignorance... but will apache still take action if a "failonstatus" is set
> (for example, to 503) if AJP is the communication medium to the
> balancer-member?  I assume apache can deduce the HTTP status code
> regardless of the protocol used to the back-end server, but I dislike
> assumptions. :)

I think that should be fine but have never tested it myself. When I
wrote the patch, my testing was all over http - I don't recall adding
any protocol specific logic. Please do report back if you come across
any complications.

-- 
Daniel Ruggeri


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Balancer logic on a per-context basis

Posted by kh...@oreillyauto.com.
Hello Daniel,

> There is a failonstatus parameter you can set for each
> balancer member that will have mod_proxy_balancer mark the worker out of
> service if that status code is found

I noticed that parameter and had considered it, but wasn't sure how apache
would know to re-enable it.  Thank you for clearing that up.

I am using AJP exclusively to the balancer-members.  Forgive my
ignorance... but will apache still take action if a "failonstatus" is set
(for example, to 503) if AJP is the communication medium to the
balancer-member?  I assume apache can deduce the HTTP status code
regardless of the protocol used to the back-end server, but I dislike
assumptions. :)

Thanks.

Kyle Harper

This communication and any attachments are confidential, protected by Communications Privacy Act 18 USCS � 2510, solely for the use of the intended recipient, and may contain legally privileged material. If you are not the intended recipient, please return or destroy it immediately. Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Balancer logic on a per-context basis

Posted by Daniel Ruggeri <DR...@primary.net>.
On 5/31/2012 10:49 AM, kharper2@oreillyauto.com wrote:
> However, if I stop a context (to
> simulate a crashed app) and leave tomcat running, apache seems to consider
> the balancer member alive.  Obviously, this results in "unavailable"
> responses from Tomcat to the end user.

Hi, Kyle - with any luck, Tomcat will return a unique HTTP status code
you could use. There is a failonstatus parameter you can set for each
balancer member that will have mod_proxy_balancer mark the worker out of
service if that status code is found. I've tested this with WebSphere
which returns a 503 (Service Unavailable) if a webapp is stopped while
the container is running.

The downside here is that there's no way to "check" again before it goes
back into service - it just gets reenabled when the retry period
(default: 60 seconds) expires... so if it's still down by that time, at
least one user will be impacted before httpd takes it out of service again.

See the params for ProxyPass at
http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass

-- 
Daniel Ruggeri


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org