CPing/CPong is our notion for using small test packets to check the
status of backend connections. JK can use such test packets directly after establishing
a new backend connection (connect mode) and also directly before each request gets
send to a backend (prepost mode).
Starting with version 1.2.27 it can also be used when a connection was idle
for a long time (interval mode).
The maximum waiting time (timeout) for a CPong answer to a CPing and the idle
time in interval mode can be configured.
The test packets will be answered by the backend very fast with a minimal amount of
needed processing resources. A positive answer tells us, that the backend can be reached
and is actively processing requests. It does not detect, if some context is deployed
and working. The benefit of CPing/CPong is a fast detection of a communication
problem with the backend. The downside is a slightly increased latency.
The worker attribute ping_mode can be set to a combination of characters
to determine, in which situations test packets are used:
- C: connect mode, timeout ping_timeout overwritten by connect_timeout
- P: prepost mode, timeout ping_timeout overwritten by prepost_timeout
- I: interval mode, timeout ping_timeout, idle time connection_ping_interval
- A: all modes
Multiple values must be concatenated without any separator characters.
We recommend using all CPing tests. If your application is very latency sensitive, then
you should only use the combination of connect and interval mode.
Activating the CPing probing via ping_mode has been added in version 1.2.27.
For older versions only the connect and prepost modes exist and must be activated by
explicitely setting connect_timeout and prepost_timeout.
The worker attribute ping_timeout sets the default wait timeout
in milliseconds for CPong for all modes. By default the value is "10000"
milliseconds. The value only gets used, if you activate CPing/Cpong probes
via ping_mode. The default value should be fine, except if you experience
very long Java garbage collection pauses.
Depending on your network latency and stability, good custom values
often are between 5000 and 15000 milliseconds.
You can overwrite the timeout used for connect and prepost mode with
connect_timeout and prepost_timeout.
Remember: don't use extremely small values.
The worker attribute connect_timeout sets the wait timeout
in milliseconds for CPong during connection establishment. You can use it
if you want to overwrite the general timeout set with ping_timeout.
To use connect mode CPing, you need to enable it via ping_mode.
Since JK usually uses persistent connections, opening new connections is a
rare event. We therefore recommend activating connect mode.
Depending on your network latency and stability, good values often
are between 5000 and 15000 milliseconds.
Remember: don't use extremely small values.
The worker attribute prepost_timeout sets the wait timeout
in milliseconds for CPong before request forwarding. You can use it
if you want to overwrite the general timeout set with ping_timeout.
To use prepost mode CPing, you need to enable it via ping_mode.
Activating this type of CPing/CPong adds a small latency to each
request. Usually this is small enough and the benefit of CPing/CPong is more important.
So in general we also recommend using prepost_timeout.
Depending on your network latency and stability, good values often
are between 5000 and 10000 milliseconds.
Remember: don't use extremely small values.
Until version 1.2.27 ping_mode and ping_timeout did not
exist and to enable connect or prepost mode CPing you had to set connect_timeout
respectively prepost_timeout to some reasonable positive value.