You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tiago Braga <tb...@gmail.com> on 2013/09/19 18:41:48 UTC

mod_jk not changes IP of hostname when occurs changing of IP on DNS

In apache, the module mod_jk not changes IP of hostname when occurs
changing of IP on DNS.

Version of apache:
Server version: Apache/2.2.15 (Unix)
Server built:   Aug  2 2013 08:02:15

Version mod_jk: 1.2.37

Example:

workers.properties

worker.portalconsultoras_prd.type=ajp13
worker.portalconsultoras_prd.host=hostexample.com.br
worker.portalconsultoras_prd.port=8009

This configuration works fine.

But, when occurs change ip in the host name in DNS, the module md_jk starts
fail to connect. Follow below the log of mod_jk:

[Wed Sep 18 12:00:33 2013] [5315:140659824723936] [info]
jk_open_socket::jk_connect.c (627): connect to 107.xx.xx.220:8009 failed
(errno=115) [Wed Sep 18 12:00:33 2013] [5315:140659824723936] [info]
ajp_connect_to_endpoint::jk_ajp_common.c (995): Failed opening socket to
(107.xx.xxx.220:8009) (errno=115) [Wed Sep 18 12:00:33 2013]
[5315:140659824723936] [error] ajp_send_request::jk_ajp_common.c (1630):
(portalconsultoras_prd) connecting to backend failed. Tomcat is probably
not started or is listening on the wrong port (errno=115)

I would like a configuration of apache that avoid this problem.

Looking for the solutions in google, have turn on the "HostnameLookups",
but is inefficient.

Thanks!

-- 
Atenciosamente,
Tiago Braga Machado

Re: mod_jk not changes IP of hostname when occurs changing of IP on DNS

Posted by Tiago Braga <tb...@gmail.com>.
Hi!

Thank you very much for your help.

I'm using the AWS. So, i created an instance Linux with Apache, that send
request to ELB (Elastic Load Balance in AWS) by mod_jk, this ELB sends
request to instance Linux with Jboss.

The ELB contains a fix host, but the IP can change any time.

Do you understand the my configuration?



On Fri, Sep 20, 2013 at 5:17 AM, André Warnier <aw...@ice-sa.com> wrote:

> Tiago Braga wrote:
>
>> In apache, the module mod_jk not changes IP of hostname when occurs
>> changing of IP on DNS.
>>
>> Version of apache:
>> Server version: Apache/2.2.15 (Unix)
>> Server built:   Aug  2 2013 08:02:15
>>
>> Version mod_jk: 1.2.37
>>
>> Example:
>>
>> workers.properties
>>
>> worker.portalconsultoras_prd.**type=ajp13
>> worker.portalconsultoras_prd.**host=hostexample.com.br
>> worker.portalconsultoras_prd.**port=8009
>>
>> This configuration works fine.
>>
>> But, when occurs change ip in the host name in DNS, the module md_jk
>> starts
>> fail to connect. Follow below the log of mod_jk:
>>
>> [Wed Sep 18 12:00:33 2013] [5315:140659824723936] [info]
>> jk_open_socket::jk_connect.c (627): connect to 107.xx.xx.220:8009 failed
>> (errno=115) [Wed Sep 18 12:00:33 2013] [5315:140659824723936] [info]
>> ajp_connect_to_endpoint::jk_**ajp_common.c (995): Failed opening socket
>> to
>> (107.xx.xxx.220:8009) (errno=115) [Wed Sep 18 12:00:33 2013]
>> [5315:140659824723936] [error] ajp_send_request::jk_ajp_**common.c
>> (1630):
>> (portalconsultoras_prd) connecting to backend failed. Tomcat is probably
>> not started or is listening on the wrong port (errno=115)
>>
>> I would like a configuration of apache that avoid this problem.
>>
>> Looking for the solutions in google, have turn on the "HostnameLookups",
>> but is inefficient.
>>
>
> .. and has nothing to do at all with the issue that you have.
>  "HostnameLookups" (in Apache httpd), as far as I remember, is only for
> logging the *origin* of a request.
>
> The basic issue here is this :
> The mod_jk connector is written in such a way that it is very fast in
> transmitting requests from Apache httpd to Tomcat (we are talking ms or
> less).
> If each time it transmits a request to Tomcat, it had to do a DNS lookup
> before, this would be terrible for performance (a DNS lookup can take many
> many milliseconds).
> So it does not do that.  With your configuration, it does a lookup once,
> when it reads its configuration, and then it caches the result (the IP
> address) and re-uses that cached IP address for all subsequent requests.
> There is nothing that you should or could change about that, otherwise the
> response time of your application is going to be just terrible.
>
> Now the question becomes another one : it is quite unusual for a Tomcat
> server (and any server) to be bound to an IP address that changes.
> Why is that the case here ? Explain your configuration and the context a
> bit more, if you want better help.
>
> Note : as a shortcut, if both your Apache httpd and your Tomcat are on the
> same host, then just do this :
> worker.portalconsultoras_prd.**host=127.0.0.1
> (and make sure that the AJP Connector in Tomcat is listening on that
> address).
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<us...@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Atenciosamente,
Tiago Braga Machado

Re: mod_jk not changes IP of hostname when occurs changing of IP on DNS

Posted by André Warnier <aw...@ice-sa.com>.
Tiago Braga wrote:
> In apache, the module mod_jk not changes IP of hostname when occurs
> changing of IP on DNS.
> 
> Version of apache:
> Server version: Apache/2.2.15 (Unix)
> Server built:   Aug  2 2013 08:02:15
> 
> Version mod_jk: 1.2.37
> 
> Example:
> 
> workers.properties
> 
> worker.portalconsultoras_prd.type=ajp13
> worker.portalconsultoras_prd.host=hostexample.com.br
> worker.portalconsultoras_prd.port=8009
> 
> This configuration works fine.
> 
> But, when occurs change ip in the host name in DNS, the module md_jk starts
> fail to connect. Follow below the log of mod_jk:
> 
> [Wed Sep 18 12:00:33 2013] [5315:140659824723936] [info]
> jk_open_socket::jk_connect.c (627): connect to 107.xx.xx.220:8009 failed
> (errno=115) [Wed Sep 18 12:00:33 2013] [5315:140659824723936] [info]
> ajp_connect_to_endpoint::jk_ajp_common.c (995): Failed opening socket to
> (107.xx.xxx.220:8009) (errno=115) [Wed Sep 18 12:00:33 2013]
> [5315:140659824723936] [error] ajp_send_request::jk_ajp_common.c (1630):
> (portalconsultoras_prd) connecting to backend failed. Tomcat is probably
> not started or is listening on the wrong port (errno=115)
> 
> I would like a configuration of apache that avoid this problem.
> 
> Looking for the solutions in google, have turn on the "HostnameLookups",
> but is inefficient.

.. and has nothing to do at all with the issue that you have.  "HostnameLookups" (in 
Apache httpd), as far as I remember, is only for logging the *origin* of a request.

The basic issue here is this :
The mod_jk connector is written in such a way that it is very fast in transmitting 
requests from Apache httpd to Tomcat (we are talking ms or less).
If each time it transmits a request to Tomcat, it had to do a DNS lookup before, this 
would be terrible for performance (a DNS lookup can take many many milliseconds).
So it does not do that.  With your configuration, it does a lookup once, when it reads its 
configuration, and then it caches the result (the IP address) and re-uses that cached IP 
address for all subsequent requests.
There is nothing that you should or could change about that, otherwise the response time 
of your application is going to be just terrible.

Now the question becomes another one : it is quite unusual for a Tomcat server (and any 
server) to be bound to an IP address that changes.
Why is that the case here ? Explain your configuration and the context a bit more, if you 
want better help.

Note : as a shortcut, if both your Apache httpd and your Tomcat are on the same host, then 
just do this :
worker.portalconsultoras_prd.host=127.0.0.1
(and make sure that the AJP Connector in Tomcat is listening on that address).


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


Re: mod_jk not changes IP of hostname when occurs changing of IP on DNS

Posted by André Warnier <aw...@ice-sa.com>.
Tiago Braga wrote:
> Hi,
> 
> I would like be automatic.

1) read this page carefully : http://tomcat.apache.org/lists.html
Particularly : "Important", item 6.

2) try to understand the answers which you have already been given.
Do not waste other people's time.

We understand that you would like this to be automatic, but the point is, it isn't 
automatic and it cannot be, for the reasons given before.

You can automate it yourself, using the scheme that Mladen indicated, but it has to be 
outside of httpd itself.  Create a watchdog program, which detects when the IP changes, 
and have it trigger a httpd graceful restart.
Or, much better, find another infrastructure where the IP address of the Tomcat servers 
does not change.

--------------

Ok, one more try to explain :
The only way to make this "automatic" within mod_jk, would be to have mod_jk do a DNS 
lookup *at every request* to verify if the IP address of the worker Tomcat has changed.
That would cause an enormous performance hit, which would probably make your application 
(and any other application) unworkable.
(And also, the people running that DNS server would probably complain)

In other words, the infrastructure which you have chosen (or which you are forced to use) 
does not match well with the configuration that you are trying to use.

You can persist trying to eat soup using a fork, but it is likely to be frustrating in the 
end.


> 
> Thanks.
> 
> 
> On Fri, Sep 20, 2013 at 12:29 PM, Mladen Turk <mt...@apache.org> wrote:
> 
>> On 09/19/2013 06:41 PM, Tiago Braga wrote:
>>
>>> In apache, the module mod_jk not changes IP of hostname when occurs
>>> changing of IP on DNS.
>>>
>>>
>> Do a graceful restart of httpd when address changes.
>> Unfortunately like some said, we can either do a DNS lookup
>> every time which would be a performance disaster or cache
>> it and reuse (like we do).
>> So graceful restart will cache a new DNS address.
>>
>> Anyhow, I'd suggest you use fixed IP addresses for your backend
>> servers anyhow.
>>
>>
>> Regards
>> --
>> ^TM
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<us...@tomcat.apache.org>
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> 


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


Re: mod_jk not changes IP of hostname when occurs changing of IP on DNS

Posted by Mladen Turk <mt...@apache.org>.
On 09/20/2013 07:29 PM, Tiago Braga wrote:
> Hi,
>
> I would like be automatic.
>

The only thing we can do is to make directive
for expiring the resolved address cache entry after some timeout.
This however would not solve the "random" DNS change
I think that this "random" is not actually random
but rather happens on some interval.



Regards
-- 
^TM

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


Re: mod_jk not changes IP of hostname when occurs changing of IP on DNS

Posted by Tiago Braga <tb...@gmail.com>.
Hi,

I would like be automatic.

Thanks.


On Fri, Sep 20, 2013 at 12:29 PM, Mladen Turk <mt...@apache.org> wrote:

> On 09/19/2013 06:41 PM, Tiago Braga wrote:
>
>> In apache, the module mod_jk not changes IP of hostname when occurs
>> changing of IP on DNS.
>>
>>
> Do a graceful restart of httpd when address changes.
> Unfortunately like some said, we can either do a DNS lookup
> every time which would be a performance disaster or cache
> it and reuse (like we do).
> So graceful restart will cache a new DNS address.
>
> Anyhow, I'd suggest you use fixed IP addresses for your backend
> servers anyhow.
>
>
> Regards
> --
> ^TM
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<us...@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Atenciosamente,
Tiago Braga Machado

Re: mod_jk not changes IP of hostname when occurs changing of IP on DNS

Posted by Mladen Turk <mt...@apache.org>.
On 09/19/2013 06:41 PM, Tiago Braga wrote:
> In apache, the module mod_jk not changes IP of hostname when occurs
> changing of IP on DNS.
>

Do a graceful restart of httpd when address changes.
Unfortunately like some said, we can either do a DNS lookup
every time which would be a performance disaster or cache
it and reuse (like we do).
So graceful restart will cache a new DNS address.

Anyhow, I'd suggest you use fixed IP addresses for your backend
servers anyhow.


Regards
-- 
^TM

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