You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Rodrigo Ramele <rr...@gmail.com> on 2006/08/10 21:42:35 UTC

Working on mod_jk

Hello Tomcat dev:

Suse 9.2, Apache 2.2.3, mod_jk 1.2.15

I am changing the way mod_jk transfer request to different workers (tomcat
instances) in a balanced worker keeping track of the link between session
and worker, and I need to use some kind of shared memory inside mod_jk.  (I
need to share a hashtable).  Could you please give me a clue on which set of
Apache API calls I could use to do it ?

Thank you very much !!!!

Re: Working on mod_jk

Posted by Rodrigo Ramele <rr...@gmail.com>.
Rainer, Jean, thank you both of you !

>mod_jk already uses shared memory, but since it should >work for apache
>1.3 and 2.0/2.2 it does not use apr. If your extensions are >only meant
>for 2.0/2.2, then have a look at apr:

>http://apr.apache.org/docs/apr/modules.html

I think I only meant it for apache 2.0/2.2 so  I will check this ... at
least to reach to a working solution.

I'm not sure, that I understand your use case. Isn't Enhydra able to
> include the node info in the cookie, or maybe you are able to set
> another cookie with the node info, so that the balancer doesn't have to
> keep state.


Exactly, Enhydra is not able to include the node info in the cookie (cannot
set something like 8FAB8...23AB.ajp13-server1 as jsessionid), so the request
is not properly redirect to the correct worker, and I cannot login.


>Yep. My question was: How do you decide in httpd that a >JSESSIONID is
>not longer valid to remove the corresponding element in >your hashtable?

Is a good point.  I suppose I could set a timestamp and keep checking it
(replicating the session timeout web.xml configuration scheme).  Is there
any way I could ask the tomcat if some specific jsessionid is longer valid ?

>I have created the slotmem for that (is in the httpd >branche
httpd-proxy-scoreboard).

I will check it out, thank you !!!

>> > Suse 9.2, Apache 2.2.3, mod_jk 1.2.15
> >> >
>

Re: Working on mod_jk

Posted by Rainer Jung <ra...@kippdata.de>.
mod_jk already uses shared memory, but since it should work for apache
1.3 and 2.0/2.2 it does not use apr. If your extensions are only meant
for 2.0/2.2, then have a look at apr:

http://apr.apache.org/docs/apr/modules.html

I'm not sure, that I understand your use case. Isn't Enhydra able to
include the node info in the cookie, or maybe you are able to set
another cookie with the node info, so that the balancer doesn't have to
keep state.

Regards,

Rainer


Rodrigo Ramele schrieb:
> Hello Jean, !
> Thanks for answering....I didn't explain myself very well.  I meant: I need
> to keep track each one of the JSESSIONID  and the worker  where the
> 'Set-Cookie' header comes from, so when a new Request with this cookie
> arrives again (from the browser) i would properly redirect it to the
> correct
> worker, where the tomcat that created this cookies is connected.  It is
> impossible for me to use sticky_session or session replication, because
> I am
> using an Enhydra Framework inside Tomcat and it handles the session itself.
> So, I need some kind of "Spanning Tree" scheme.  Now I am using the file
> system to store the hashtable and I want to know if I could use some
> kind of
> shared memory inside Apache ...
> 
> On 8/10/06, Jean-frederic Clere <jf...@gmail.com> wrote:
>>
>> Rodrigo Ramele wrote:
>>
>> > Hello Tomcat dev:
>> >
>> > Suse 9.2, Apache 2.2.3, mod_jk 1.2.15
>> >
>> > I am changing the way mod_jk transfer request to different workers
>> > (tomcat
>> > instances) in a balanced worker keeping track of the link between
>> session
>> > and worker, and I need to use some kind of shared memory inside mod_jk.
>>
>> How do you decide to that a session has timeout? (Guessing that session
>> means jsessionid identified sessions).
>>
>> Cheers
>>
>> Jean-Frederic
>>
>> > (I
>> > need to share a hashtable).  Could you please give me a clue on which
>> > set of
>> > Apache API calls I could use to do it ?
>> >
>> > Thank you very much !!!!
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
> 

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


Re: Working on mod_jk

Posted by Rainer Jung <ra...@kippdata.de>.
If your platform uses multiple processes for Apache, then traditional in
memory data will not be shared. You'll need to use shared memory for
that. Have a look at Jean-Cleres hints in the same thread about the
slotmem implementation he was doing a couple of weeks ago in the httpd
project.

Regards,

Rainer

Rodrigo Ramele schrieb:
> Tomcat gurus:
> 
> I am working with apr table in mod_jk to store the session table but i
> can't
> achieve to share the table between differents requests... Someone could
> give
> me a tip ? (or a good reference to a site or book related with apache 2
> module programming)
> 
> Thanks a lot !!!
> 
> 
> On 8/14/06, Rainer Jung <ra...@kippdata.de> wrote:
>>
>> Klaus Wagner wrote:
>> > On Mon, 2006-08-14 at 16:24 +0200, Rainer Jung wrote:
>> >
>> >>Klaus Wagner wrote:
>> >>...
>> >>If you really, really want to do this, for the watchdog you can enhance
>> >>the existing maintain methods. There is already a mechanism that calls
>> >>the maintain methods during a request only if the last call to it is
>> >>longer ago than worker.maintain seconds (Default: 60 seconds). The
>> >>method is called during request work, so it must be stable and fast
>> >
>> >
>> > I don't want to do anything, just giving impressions how I would do
>> if I
>> > had to do but thanks. Good to know that there is pretty much everything
>> > there that would be needed.
>> >
>> > regards Klaus
>>
>> I wanted to adress the original poster :)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
> 

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


Re: Working on mod_jk

Posted by Rodrigo Ramele <rr...@gmail.com>.
Tomcat gurus:

I am working with apr table in mod_jk to store the session table but i can't
achieve to share the table between differents requests... Someone could give
me a tip ? (or a good reference to a site or book related with apache 2
module programming)

Thanks a lot !!!


On 8/14/06, Rainer Jung <ra...@kippdata.de> wrote:
>
> Klaus Wagner wrote:
> > On Mon, 2006-08-14 at 16:24 +0200, Rainer Jung wrote:
> >
> >>Klaus Wagner wrote:
> >>...
> >>If you really, really want to do this, for the watchdog you can enhance
> >>the existing maintain methods. There is already a mechanism that calls
> >>the maintain methods during a request only if the last call to it is
> >>longer ago than worker.maintain seconds (Default: 60 seconds). The
> >>method is called during request work, so it must be stable and fast
> >
> >
> > I don't want to do anything, just giving impressions how I would do if I
> > had to do but thanks. Good to know that there is pretty much everything
> > there that would be needed.
> >
> > regards Klaus
>
> I wanted to adress the original poster :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: Working on mod_jk

Posted by Rainer Jung <ra...@kippdata.de>.
Klaus Wagner wrote:
> On Mon, 2006-08-14 at 16:24 +0200, Rainer Jung wrote:
> 
>>Klaus Wagner wrote:
>>...
>>If you really, really want to do this, for the watchdog you can enhance 
>>the existing maintain methods. There is already a mechanism that calls 
>>the maintain methods during a request only if the last call to it is 
>>longer ago than worker.maintain seconds (Default: 60 seconds). The 
>>method is called during request work, so it must be stable and fast
> 
> 
> I don't want to do anything, just giving impressions how I would do if I
> had to do but thanks. Good to know that there is pretty much everything
> there that would be needed.
> 
> regards Klaus

I wanted to adress the original poster :)

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


Re: Working on mod_jk

Posted by Klaus Wagner <kl...@it-austria.net>.
On Mon, 2006-08-14 at 16:24 +0200, Rainer Jung wrote:
> Klaus Wagner wrote:
> ...
> > 4. the tricky part: have a) a watchdog that clears invalid sessions in
> > idle time or b) clear sessions before looking for them (causes some
> > performance issues)
> > 
> 
> If you really, really want to do this, for the watchdog you can enhance 
> the existing maintain methods. There is already a mechanism that calls 
> the maintain methods during a request only if the last call to it is 
> longer ago than worker.maintain seconds (Default: 60 seconds). The 
> method is called during request work, so it must be stable and fast

I don't want to do anything, just giving impressions how I would do if I
had to do but thanks. Good to know that there is pretty much everything
there that would be needed.

regards Klaus


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


Re: Working on mod_jk

Posted by Rainer Jung <ra...@kippdata.de>.
Klaus Wagner wrote:
...
> 4. the tricky part: have a) a watchdog that clears invalid sessions in
> idle time or b) clear sessions before looking for them (causes some
> performance issues)
> 

If you really, really want to do this, for the watchdog you can enhance 
the existing maintain methods. There is already a mechanism that calls 
the maintain methods during a request only if the last call to it is 
longer ago than worker.maintain seconds (Default: 60 seconds). The 
method is called during request work, so it must be stable and fast

Regards,

Rainer



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


Re: Working on mod_jk

Posted by Klaus Wagner <kl...@it-austria.net>.
On Fri, 2006-08-11 at 09:51 +0200, Jean-frederic Clere wrote:
> Rodrigo Ramele wrote:
> 
> > Hello Jean, !
> > Thanks for answering....I didn't explain myself very well.  I meant: I 
> > need
> > to keep track each one of the JSESSIONID  and the worker  where the
> > 'Set-Cookie' header comes from, so when a new Request with this cookie
> > arrives again (from the browser) i would properly redirect it to the 
> > correct
> > worker, where the tomcat that created this cookies is connected.
> 
> Yep. My question was: How do you decide in httpd that a JSESSIONID is 
> not longer valid to remove the corresponding element in your hashtable?
As having this done for another project the solution is quite simple:

1. for every id in the hashtable record a timestamp/counter
2. (re)set the timecounter every time the sessionid shows up (both
directions would be great - else user->server is sufficent)
3. make the sessiontimeout "managable" meaning an option in the config
file. Normally the Applaction Layer Sessions have defined timeouts.
Otherwise use a higher value then the Application reasonable does or as
high as possible without doing too much pressure on the system.
4. the tricky part: have a) a watchdog that clears invalid sessions in
idle time or b) clear sessions before looking for them (causes some
performance issues)


regards Klaus


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


Re: Working on mod_jk

Posted by Jean-frederic Clere <jf...@gmail.com>.
Rodrigo Ramele wrote:

> Hello Jean, !
> Thanks for answering....I didn't explain myself very well.  I meant: I 
> need
> to keep track each one of the JSESSIONID  and the worker  where the
> 'Set-Cookie' header comes from, so when a new Request with this cookie
> arrives again (from the browser) i would properly redirect it to the 
> correct
> worker, where the tomcat that created this cookies is connected.

Yep. My question was: How do you decide in httpd that a JSESSIONID is 
not longer valid to remove the corresponding element in your hashtable?

>   It is
> impossible for me to use sticky_session or session replication, 
> because I am
> using an Enhydra Framework inside Tomcat and it handles the session 
> itself.
> So, I need some kind of "Spanning Tree" scheme.  Now I am using the file
> system to store the hashtable and I want to know if I could use some 
> kind of
> shared memory inside Apache ...

I have created the slotmem for that (is in the httpd branche 
httpd-proxy-scoreboard).

Cheers

Jean-Frederic

>
> On 8/10/06, Jean-frederic Clere <jf...@gmail.com> wrote:
>
>>
>> Rodrigo Ramele wrote:
>>
>> > Hello Tomcat dev:
>> >
>> > Suse 9.2, Apache 2.2.3, mod_jk 1.2.15
>> >
>> > I am changing the way mod_jk transfer request to different workers
>> > (tomcat
>> > instances) in a balanced worker keeping track of the link between
>> session
>> > and worker, and I need to use some kind of shared memory inside 
>> mod_jk.
>>
>> How do you decide to that a session has timeout? (Guessing that session
>> means jsessionid identified sessions).
>>
>> Cheers
>>
>> Jean-Frederic
>>
>> > (I
>> > need to share a hashtable).  Could you please give me a clue on which
>> > set of
>> > Apache API calls I could use to do it ?
>> >
>> > Thank you very much !!!!
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
>


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


Re: Working on mod_jk

Posted by Rodrigo Ramele <rr...@gmail.com>.
Hello Jean, !
Thanks for answering....I didn't explain myself very well.  I meant: I need
to keep track each one of the JSESSIONID  and the worker  where the
'Set-Cookie' header comes from, so when a new Request with this cookie
arrives again (from the browser) i would properly redirect it to the correct
worker, where the tomcat that created this cookies is connected.  It is
impossible for me to use sticky_session or session replication, because I am
using an Enhydra Framework inside Tomcat and it handles the session itself.
So, I need some kind of "Spanning Tree" scheme.  Now I am using the file
system to store the hashtable and I want to know if I could use some kind of
shared memory inside Apache ...

On 8/10/06, Jean-frederic Clere <jf...@gmail.com> wrote:
>
> Rodrigo Ramele wrote:
>
> > Hello Tomcat dev:
> >
> > Suse 9.2, Apache 2.2.3, mod_jk 1.2.15
> >
> > I am changing the way mod_jk transfer request to different workers
> > (tomcat
> > instances) in a balanced worker keeping track of the link between
> session
> > and worker, and I need to use some kind of shared memory inside mod_jk.
>
> How do you decide to that a session has timeout? (Guessing that session
> means jsessionid identified sessions).
>
> Cheers
>
> Jean-Frederic
>
> > (I
> > need to share a hashtable).  Could you please give me a clue on which
> > set of
> > Apache API calls I could use to do it ?
> >
> > Thank you very much !!!!
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: Working on mod_jk

Posted by Jean-frederic Clere <jf...@gmail.com>.
Rodrigo Ramele wrote:

> Hello Tomcat dev:
>
> Suse 9.2, Apache 2.2.3, mod_jk 1.2.15
>
> I am changing the way mod_jk transfer request to different workers 
> (tomcat
> instances) in a balanced worker keeping track of the link between session
> and worker, and I need to use some kind of shared memory inside mod_jk.

How do you decide to that a session has timeout? (Guessing that session 
means jsessionid identified sessions).

Cheers

Jean-Frederic

> (I
> need to share a hashtable).  Could you please give me a clue on which 
> set of
> Apache API calls I could use to do it ?
>
> Thank you very much !!!!
>


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