Hi all,

To whom it may satisfy...



Here is some code that can be used for starting mod_ajp for Apache2.0/2.1.
You are welcome to join :)

It can be downloaded from:
http://www.apache.org/~mturk/modajp.tar.gz


Some rationale:

I spoke with Henri and we decided that although mod_proxy with proxy_ajp is a
good idea (in the long term... very long term), we need something that will
fill in the gaps.
The code dealing with communication using sockets will be from jk/jk2 as well
as AJP protocol.
Also, in the next version it will support AJP13+ or AJP14 protocol extensions
including simple crypto and compression to either secure or lower the
bandwidth of the transportation channel, together with service channels for
basic lb statuses and typical 'going-down-[in xxx
seconds]-do-not-accept-any-new-sessions' sittuations (not sure about
autodiscovery).


The code itself has only implemented configuration, uri matching, and a simple
hanlder just displaying selected worker/balancer.

Here is how the httpd.config looks after:
LoadModule ajp_module modules/mod_ajp.so


<AjpWorker ajp1>
    AjpHost localhost:8009
    AjpLbFactor 30
</AjpWorker>

<AjpWorker ajp2>
    AjpHost otherhost:8009
</AjpWorker>

<AjpWorker ajp3>
    AjpHost thirdhost
    AjpPort 8009
    AjpLbFactor
</AjpWorker>


<AjpLoadBalancer lba>
    AjpWorkerAdd ajp1
    AjpWorkerAdd ajp3:30
    AjpStickySession On
</AjpLoadBalancer>

<AjpLoadBalancer lbb>
    AjpWorkerAdd ajp2
    AjpWorkerAdd ajp3:70
    AjpStickySession On
</AjpLoadBalancer>

About Worker:

Worker is a cnnector to remote TC instance.
It maintains a connection socket pool (mix...max), with configurable cleanup
time for extra max-min sockets.
All the configurable socket params from jk/jk2 are implemented, like
keep-alive, timeout, etc...

About LoadBalancer:

Each LoadBalancer maintains It's own lb status for each worker, so that you
can have different lb schemes for same workers (the thing I was looking to
implement in jk2, but it would require too much coding).
It basically enables that workerA in lbA works on 30% load while the same
workerA in lbB works with 50% load, etc...
Also the LbFactors are in percentages (finally), and also normalized on
post_config, meaning that if you don't specify the lbfactor it will get
computed, counting already set factors, so that the sum of all factors in
particular lb is 100.
The sticky session does not need to be 'jsessionid', but can rather be
configurable, perhaps with 'jvmroute'. Just use 'AjpStickySession jvmroute'
directive.
It has also the AjpStickySessionForce On|Off, that returns 503 when worker is
bussy or down actually enabling or disabling failover if there is no session
replication on backend servers.


Uri Mappings:

There are four directives for uri mappings with different scenarios.

'AjpMount /examples lba' behaves just like JkMount,
Or you can:
<Location /examples>
   AjpMount lba
</Location>

There is also AjpNoMount directive that behaves like the name implies.
<Location /examples>
   AjpMount lba
   AjpNoMount *.gif
</Location>

Each of them has Match extension that uses regular expression

<Location /examples>
   AjpMount lba
   AjpNoMountMatch \.gif$
</Location>

If the directives are used inside server root they are considered 'global' and
are potentially propagated to each virtual host if you specify:
'AjpOptions Inherit' directive.
You can at any time use 'AjpOptions -Inherit' to suppress further inheritance.
So you can:

AjpOptions Inherit
AjpMount *.jsp lba
And each vhost will have the registered *.jsp going trough lba worker.


Also, all directives inside <Files or <FilesMatch are considered global too
(regitered to the server conf).


Other stuff:

Mod_ajp has a hook for status module, so you can see all the configured
workers and loadbalancers using /server-status.
This will actually display the runtime status of each worker like
bytes-transferred, etc... (something like jkstatus).
There is also ajp-info handler
<Location /ajp-info>
  SetHandler ajp-info
</Location>
and can be used to display other non-runtime infos like uri mappings, etc...
If we need that after all.


List of all implemented directives:

<AjpWorker - Container for directives affecting workers
<AjpLoadBalancer - Container for directives affecting load balancers
AjpMount - a virtual path and a Worker
AjpMountMatch - a virtual path expression and a Worker
AjpNoMount - Excludes the path from mounted location
AjpNoMountMatch - Excludes the pattern from mounted location
AjpOptions - List of option strings to set
AjpHost - Sets the Workers hostname[:port]
AjpPort - Sets the Workers port number
AjpLbFactor - Sets the Workers Load balancing factor
AjpWorkerAdd - Adds the worker[:LbFactor] to LoadBalancer with optional
LbFactor (in percents)
AjpStickySession - Sets the sticky-session mode On|Off|jsessionid
AjpStickySessionForce - On|Off disables or enables the session failower.
AjpReceiveBufferSize - Worker Receive buffer size in bytes
AjpIOBufferSize - Worker IO buffer size in bytes
AjpMinChannels - Minimum number of opened channels for worker
AjpMaxChannels - Maximum number of opened channels for worker
AjpCacheMaintain - Interval (in seconds) when extra opened channels gets
closed
AjpConnectTimeout - Interval (in seconds) for connect timeout to remote host
AjpReplyTimeout - Interval (in seconds) for reply from remote host
AjpSocketTimeout - Interval (in seconds) of inactivity for closing connection
AjpPrepostTimeout - Interval (in seconds) for something dealing with post
AjpKeealiveInterval - Send Keepalive message on inactive connection (in
miliseconds)


TODO:
Everything else :-)


Comments welcome,
MT.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to