109 lines
6.4 KiB
HTML
109 lines
6.4 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
|||
|
<!DOCTYPE html
|
|||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|||
|
<html lang="en-us" xml:lang="en-us">
|
|||
|
<head>
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|||
|
<meta name="security" content="public" />
|
|||
|
<meta name="Robots" content="index,follow" />
|
|||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|||
|
<meta name="DC.Type" content="topic" />
|
|||
|
<meta name="DC.Title" content="Guidelines for writing high availability CGIs" />
|
|||
|
<meta name="abstract" content="By understanding the guidelines for writing cluster-enabled CGIs, you can avoid potential problems with your CGI code." />
|
|||
|
<meta name="description" content="By understanding the guidelines for writing cluster-enabled CGIs, you can avoid potential problems with your CGI code." />
|
|||
|
<meta name="DC.Relation" scheme="URI" content="rzaieparcgi.htm" />
|
|||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2002,2006" />
|
|||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2002,2006" />
|
|||
|
<meta name="DC.Format" content="XHTML" />
|
|||
|
<meta name="DC.Identifier" content="rzag3ch4guidelines" />
|
|||
|
<meta name="DC.Language" content="en-us" />
|
|||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|||
|
<!-- US Government Users Restricted Rights -->
|
|||
|
<!-- Use, duplication or disclosure restricted by -->
|
|||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|||
|
<title>Guidelines for writing high availability CGIs</title>
|
|||
|
</head>
|
|||
|
<body id="rzag3ch4guidelines"><a name="rzag3ch4guidelines"><!-- --></a>
|
|||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|||
|
<h1 class="topictitle1">Guidelines for writing high availability CGIs</h1>
|
|||
|
<div><p>By understanding the guidelines for writing cluster-enabled CGIs,
|
|||
|
you can avoid potential problems with your CGI code.</p>
|
|||
|
<p>All CGI programs existing today are cluster-disabled. A CGI program developer
|
|||
|
should follow the following rules when writing cluster-enabled CGI programs:</p>
|
|||
|
<ul><li>Write the CGI in such a way that running them with the same state more
|
|||
|
than once does not cause any problem.</li>
|
|||
|
<li>Store the CGI program’s state between client’s requests only in the Web
|
|||
|
server.</li>
|
|||
|
<li>Use only cluster-safe mechanisms. For example, if a CGI program uses shared
|
|||
|
memory (which is currently not a cluster-safe mechanism), the macro is almost
|
|||
|
certainly cluster-disabled.</li>
|
|||
|
</ul>
|
|||
|
|
|||
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><caption>Table 1. CGI problems and solutions. This
|
|||
|
table identifies potential problem areas and suggests a solution:</caption><thead align="left"><tr><th valign="top" id="d0e31">Potential problems</th>
|
|||
|
<th valign="top" id="d0e33">Solutions</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody><tr><td valign="top" headers="d0e31 ">When the stateful CGI is run with the same state more
|
|||
|
than once, its correctness is not ensured.</td>
|
|||
|
<td valign="top" headers="d0e33 ">Rewrite the CGI so that it can run with the same state
|
|||
|
more than once.</td>
|
|||
|
</tr>
|
|||
|
<tr><td valign="top" headers="d0e31 ">The stateful CGI accesses shared memory.</td>
|
|||
|
<td valign="top" headers="d0e33 ">Eliminate the use of shared memory.</td>
|
|||
|
</tr>
|
|||
|
<tr><td valign="top" headers="d0e31 ">The stateful CGI generates session handles ignoring
|
|||
|
session handles passed by the Web server.</td>
|
|||
|
<td valign="top" headers="d0e33 ">Rewrite the CGI to use session handles passed by the
|
|||
|
Web server.</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
</div>
|
|||
|
<p>There are two categories of high availability Web server programming models
|
|||
|
to consider when writing high availability CGI programs or enabling an existing
|
|||
|
CGI program for use as a high availability CGI program. The two categories
|
|||
|
are:</p>
|
|||
|
<ul><li>Primary/backup</li>
|
|||
|
<li>Peer model</li>
|
|||
|
</ul>
|
|||
|
<p>For the primary/backup, follow these additional guidelines:</p>
|
|||
|
<p>The stateful data is saved by the high availability CGI program by calling
|
|||
|
the QzhbCgiSendState API. To retrieve any stateful data that has been stored
|
|||
|
use the QzhbCgiRecvState API. The QzhbCgiRecvState API returns stateful information
|
|||
|
when the environment variable QZHBRECOVERY is set and QZHBHA_MODEL is equal
|
|||
|
to PRIMARYBACKUP. If the QZHBRECOVERY is not set, then the CGI program should
|
|||
|
not use the QzhbCgiRecvState API. You must write a persistent
|
|||
|
CGI that maintains the data in static variables. If the environment variable
|
|||
|
QZHBRECOVERY is set, retrieve the data using the QzhbCgiRecvState API and
|
|||
|
restore the static variables.</p>
|
|||
|
<p>The Web server still limits the total number of persistent CGIs (both cluster-enabled
|
|||
|
and cluster-disabled ) using the MaxPersistentCGI directive.</p>
|
|||
|
<p>For the Peer model, follow these additional guidelines:</p>
|
|||
|
<p>The stateful data is saved by the high availability CGI program by calling
|
|||
|
the QzhbCgiSendState API. To retrieve any stateful data that has been stored
|
|||
|
use the QzhbCgiRecvState API. The QzhbCgiRecvState API must be used with each
|
|||
|
new request to retrieve any stateful data that has been stored for a previous
|
|||
|
high availability CGI program invocation. In this model your CGI program must
|
|||
|
not save stateful data in static variables.</p>
|
|||
|
<p>If QZHBHA_MODEL is PUREPEER the CGI is expected to restore its state, to
|
|||
|
serve the request, and to return its new state to the Web server. When the
|
|||
|
Web server receives the new CGI’s state, it stores the state (which will be
|
|||
|
passed to the CGI with the subsequent request), returns the response to the
|
|||
|
client, and terminates the CGI job. Consider a cluster-enabled persistent
|
|||
|
CGI program. The concept of persistency is kept, but its implementation is
|
|||
|
absolutely changed. A cluster-enabled persistent CGI program does not stay
|
|||
|
in the CGI job during a session; it is invoked each time a request comes in.
|
|||
|
However, the concept of persistency is kept due to CGI’s state (and the state
|
|||
|
of the Web server regarding the CGI) stored in the CHT and always passed to
|
|||
|
the CGI program with subsequent requests.</p>
|
|||
|
</div>
|
|||
|
<div>
|
|||
|
<div class="familylinks">
|
|||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzaieparcgi.htm" title="This topic provides information about Common Gateway Interfaces (CGI).">Common Gateway Interface</a></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</body>
|
|||
|
</html>
|