RE: Jk2: scoreboard format and semantics.

2002-04-24 Thread GOMEZ Henri

 To keep things simple and use existing code, I think we should use
 the current marshalling/demarshalling code ( ajp13 ) to store/get
 informations from each slot. 
 
 Why not just use native read/write on int/strings ?

If we treat shm as a byte[] and use java code to process it -
we can run into byte order problems, aligment, etc. It's quite 
tricky to predict how a struct will be layed out.

Ok, I understand why, you're thinking in-process tomcats
whereas I was thinking out-process tomcats (and even on
differents machines)

+1 so for ajp marshalling use


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Jk2: scoreboard format and semantics.

2002-04-23 Thread costinm

On Mon, 22 Apr 2002, GOMEZ Henri wrote:

 To keep things simple and use existing code, I think we should use
 the current marshalling/demarshalling code ( ajp13 ) to store/get
 informations from each slot. 
 
 Why not just use native read/write on int/strings ?

If we treat shm as a byte[] and use java code to process it -
we can run into byte order problems, aligment, etc. It's quite 
tricky to predict how a struct will be layed out.

If we treat the shm as a struct and use native methods to 
read fields - the code becomes more complicated and 
we have more overhead.

I'm trying both - but the first one ( using byte[] and a 
'consistent' format ) has many benefits as it reuses
a lot of existing code and will help us in many ways.

The most important 'experience' with jni worker in jk1 
is that jni has a very large overhead, especially if you 
pass strings or small things. The fewer calls, the better.

In jk2 we already use marshalling in the jni channel, 
and that seems to help performance and the code is simpler.
The same piece of code ( that avoids allocations in both
java and C ) can be used for shm channel ( which will be faster
than unix socket and work on most platforms ). And the 
code we write to unmarshall workers and other stuff 
from the shm can be reused on the socket channel
 ( i.e. ajp14 and the new APIs for autoconf - the packet can be in the shm 
or sent via ajp )

I know I'm not very clear - I'm still experimenting with
this. 

 - a tomcat process when it starts and auto-register itself ( including 
 the case of Apache multi-process where VMs are created with 
 each process )
 
 ok, a tomcat started on another boxes, but that we want to add to
 the list of known workers will be handled by jk_status/jk_control ?

Probably. Or a local command ( on the server machine ) that will add
the worker to the scoreboard.

 
 - an admin tool ( either C or an ant bean using the jkjni.so lib ) to
 register workers on different machines ( jk_status worker can 
 do that too ).
 
 ok, so jk_status became jk_control or jk_admin in that case.
 No more just a read-only task ?

Yes. Or we add a jk_control for write operations ( it would 
be cleaner probably ).
And again we can reuse the jk_msg and marshalling - jk_ctl can
take a POST and use the body with the same code that the
scoreboard is using.

Costin


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Jk2: scoreboard format and semantics.

2002-04-22 Thread GOMEZ Henri



-
Henri Gomez ___[_]
EMAIL : [EMAIL PROTECTED](. .) 
PGP KEY : 697ECEDD...oOOo..(_)..oOOo...
PGP Fingerprint : 9DF8 1EA8 ED53 2F39 DC9B 904A 364F 80E6 



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 10:34 PM
To: List Tomcat-Dev
Subject: Jk2: scoreboard format and semantics.


That's a difficult and critical issue.

The scoreboard is needed to allow the loadbalancing to react 
to changes 
in the workers. It is also help with runtime configuration of jk in
multi-process servers.

The problem is obviously how to implement it without mutexes ( or with
minimal use of interprocess synchronization ).

The first proposal is based on the model used by Apache and jserv. 

1. Each worker will get it's own 'slot'. 
   Each slot and the jk_shm_head will get a 'version' ( or 'serial' ) 
field. 

2. Whenever a worker ( tomcat ) is created, we create a slot - this 
operation requires inter-process locking ( for the unlikely 
but possible 
case 2 tomcat instances will start at the same time ).

3. Any change in the slots will result in incrementing ( or just 
changing ) the version in the slot and in the head.

4. jk_worker_lb will just monitor the int field in the head. 
If a change
is detected ( from the previous value ) - it'll walk all fields
and update the worker map. 

The same process could work for doing updates in the uriMap and other 
config changes - but later. 

My current understanding is that this model will does not require 
extra synchronization or even atomic operations on read ( i.e. in the
critical path ). Even if we read the version while changing - what we
care is if the value is different from the last one we read. ( atomic
operations are usually expensive - and not trivial on MP systems ).

The creation or change in slots will require synchronization. The 
'bad' thing that can happen is a process reading the slot while we
change it. My initial thinking was that we could have a 'changing' 
field in the slot - but I don't think we can have guarantee of the 
order of the writes. But a simple CRC of the data would work - 
the reader will copy the slot, then do a CRC. If it doesn't 
match, it'll
either keep the old data or try again.

The information in the slot will include the worker id ( used in 
the 'session id' or jvmRoute ), information about the channels it 
supports ( host:port, unix domain, etc ), state. 

To keep things simple and use existing code, I think we should use
the current marshalling/demarshalling code ( ajp13 ) to store/get
informations from each slot. 

Why not just use native read/write on int/strings ?

Do you think we should share these shared informations with 
others apps/modules ?

To keep things simple, we should start with fixed-size slots. 

The shm scoreboard will be updated by:
- the lb worker ( when it detects that a worker is down ) 

ok

- a tomcat process when it starts and auto-register itself ( including 
the case of Apache multi-process where VMs are created with 
each process )

ok, a tomcat started on another boxes, but that we want to add to
the list of known workers will be handled by jk_status/jk_control ?

- an admin tool ( either C or an ant bean using the jkjni.so lib ) to
register workers on different machines ( jk_status worker can 
do that too ).

ok, so jk_status became jk_control or jk_admin in that case.
No more just a read-only task ?

Comments ? Other ideas ? 


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]