CSP Gateway Configuration Guide - InterSystems Documentation
CSP Gateway Configuration Guide - InterSystems Documentation
CSP Gateway Configuration Guide - InterSystems Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
State-Aware Sessions (Preserve mode 1)<br />
than the number of threads allowed per process (ThreadsPerChild) potentially leads to queuing in the <strong>Gateway</strong> modules<br />
since Apache can potentially allocate more work to each worker process than can be handled by the number of allowed<br />
connections to Caché. Such a configuration can potentially lead to congestion in the Apache environment so care should<br />
therefore be taken.<br />
For installations where most of the Apache workload is made up of <strong>CSP</strong> requests, it is better to not assign a value to the<br />
<strong>Gateway</strong>’s Maximum Server Connections directive and control the amount of concurrent work that can be done (and by<br />
implication the number of connections to Caché) with the corresponding Apache configuration parameters.<br />
Setting an independent value for the <strong>Gateway</strong>’s Maximum Server Connections directive would, however, make sense in<br />
installations where <strong>CSP</strong> requests only represent part of the workload for the Apache installation as a whole.<br />
D.2 State-Aware Sessions (Preserve mode 1)<br />
Support for state-aware sessions in a web server that distributes load over multiple worker processes relies on InterProcess<br />
Communications (IPC) protocols to manage the routing of requests between individual worker processes. Operating in this<br />
web server architecture, the <strong>Gateway</strong> has no control over which worker process will handle any particular request.<br />
The <strong>Gateway</strong> uses UNIX domain sockets for its IPC protocol and the method for supporting state-aware sessions is described<br />
below.<br />
As an example, consider a web server installation that distributes its load over 3 worker processes: P1, P2 and P3. Each<br />
worker process can potentially start any number of threads (T1, T2 … Tn) according to the web server MPM and configuration<br />
in use.<br />
Suppose an application makes a request to mark its session as state-aware (preserve mode 1) and the <strong>Gateway</strong> acknowledges<br />
this instruction in process P2. The connection and (security context) to the, now private Caché process is hosted by web<br />
server worker process P2. All further requests for that user/session must now be processed by worker process P2. However,<br />
the <strong>Gateway</strong> has no control over which worker process the web server will route subsequent requests to so the <strong>Gateway</strong><br />
must establish an IPC channel between P2 and (potentially) any other worker process in the set.<br />
When the <strong>Gateway</strong> marks the connection as state-aware in P2 it starts a listening service in a separate, detached, thread. If<br />
<strong>Gateway</strong> Log Level v2 is in use, a message similar to the one shown below is written to the Event Log.<br />
IPC Server<br />
Process ID: 28457 Listening on Domain Socket: /tmp/csp28457.str<br />
Now, let’s say a further request for the same session is processed by worker process P3. The <strong>Gateway</strong> will forward that<br />
request to process P2 via the IPC channel previously established and wait for the response. If Log Level v2 is in use then<br />
a message similar to the one shown below is recorded:<br />
Route request over IPC to another web server process<br />
PrivateSession=2; pid_self=28456; ipc_to_pid=28457;<br />
Of course, if a request for the session happens to be routed by the web server directly to P2 then no further routing is necessary<br />
in the <strong>Gateway</strong> environment since P2 is hosting the session’s private connection.<br />
If, for whatever reason, the <strong>Gateway</strong> is unable to connect and forward a request to a previously created IPC channel, one<br />
of the following messages is recorded depending on the context in which the error was raised:<br />
IPC CLIENT: Error<br />
Cannot connect<br />
Or:<br />
IPC CLIENT: Error<br />
Cannot send request<br />
<strong>CSP</strong> <strong>Gateway</strong> <strong>Configuration</strong> <strong>Guide</strong> 149