About the name CRINOID

I started this project a couple of years ago, using the name "SQUID" for a jet-propelled multi-tentacled mollusc. Since then, some sofware giant came out with a proxy server of that name.

So to avoid confusion (and to get a kewl domain name), I've renamed the CGI server to "CRINOID". It still has multiple arms :-)

Some history

A couple of years ago, I wanted to do some CGIs to illustrate and publicize a neutrino oscillation experiment that I'm involved with, but found that the speed of the Perl CGIs was just too slow to make it feasible.

Perl was fast enough to do the calculations I needed (showing distortion of a neutrino energy spectrum caused by oscillations), and display the results in a nice graph, but it was the startup time that was the killer.

Soon after, I started putting class materials on the Web, and wanted some instructional CGIs...but I *knew* that the students are an impatient bunch and would hit the "stop" button if a script took more than a few seconds to respond.

CRINOID is the result of trying to put fast Perl CGIs on the OSU HTTP server. And while some of my more recent instructional CGIs are slow for computational reasons (like my CGI for tracing light rays around a black hole), much of the startup penalty has been eliminated.

Some advantages:

The speed advantage is more noticeable with CGIs that produce GIF output because the graphics package slows down Perl startup. In addition, the extra steps needed for "normal" CGIs to produce GIFs (writing to tempfile, copying to server) are eliminated. An example, here's STARS.PL that produces a random starfield. It's a ".com" file because we have to set up PGPLOT and redirect the output to a temp file that is then copied to the HTTP server for output (STARS.COM source).

With CRINOID, one can run the Perl directly CRINOID STARS.PL without a COM-file wrapper. While there may not seem to be huge speed differences, check the information below about script "reusablity", which gives another appreciable speed increase.

What CRINOID does

CRINOID is a Perl CGI-server for the OSU HTTP server. When a URL is requested that the HTTP server maps to an 'exec' rule (meaning: "run a CGI for this one"), it sends the request to CRINOID which handles running the CGI and sends the results back through the HTTP server.

Before this gets too complicated, here's a diagram of the various components that make up CRINOID.

Why a server for that?

Well, CRINOID handles multiple persistent processes, each with Perl (and modules) pre-loaded. You can configure how many processes are present (minimum and maximum) and how many of those are allowed to be idle (minimum and maximum).

This allows one to "tune" the resource usage and responsivness of the CGIs...scripts that are heavily used can be assigned to a "group" of processes that have different min/max settings than scripts that are lightly used.

CRINOID itself (as opposed to the individual Perl-processes, which I call TENTACLEs) is multi-threaded, so it can respond quickly to requests, sending them off to various TENTACLE processes.

TENTACLEs

The TENTACLE processes have Perl embedded in them, and are meant to be run in different VMS accounts than the CRINOID process. This means that each user can have their own CGI's, with simplified security: a user's CGIs can only affect their own account.

When CRINOID starts up a TENTACLE process, it loads Perl, loads up any modules that are set for "pre-loading" (things like PGPLOT, that are slow to start are good candidates for this) and waits for requests from CRINOID.

CRINOID sends TENTACLE a request with the %ENV data for running the script, TENTACLE pushes the %ENV data into Perl and runs the script, piping its input and output from CRINOID. After the script is run, TENTACLE cleans up and resets, waiting for another request.

If the same script is requested of TENTACLE, it can be simply re-run, saving the compilation time. This is not the default however, because a script that is re-run will already have been initialized. If your script counts on "uninitialized" variables, then it shouldn't be re-run:

    if (!defined($x)) {  # $x isn't defined first time script is run
        ...do stuff..
    }
    $x = 123;

In most cases, such scripts generate "uninitialized variable" complaints when run with $ perl -w. Good coding practice will result in scripts that can be reliably re-run, in which case you just set the variable (inside the script):

    $CRINOID::Reuse = 1;
which will flag the script as reusable. For backward compatibility, the $SQUID::Reuse flag is also accepted.

Remember the STARS.PL script up above? Well, here's the same script (source), only with $CRINOID::Reuse set. You can try it here. Hit "reload" a few times to test responsiveness and compare.

Running CRINOID for users

A useful feature for user CGIs is that some individual configuration can be specified to make the CGIs more efficient. You do this by creating a OYSTER.CONFIG file in the users SYS$LOGIN directory:
    # example OYSTER.CONFIG
    #
    #
    preload PGPLOT
    preload Digest::MD5
    errlog  oyster.log
    loglevel 3
The "preloads" are modules to be preloaded when each Tentacle starts up. The "errlog" and "loglevel" refer to logging that is done by the Oyster perl wrapper code. See the OYSTER. script for more detail.

The errlog file gives you information about what modules are preloaded and which scripts were run. For example:

    Running script phys151 at Thu Dec  9 08:51:31 1999
    Preloads: UNIVERSAL DynaLoader Socket Digest::MD5 PGPLOT
    Script: /DISK$USERS/LANE/www-cgi phys151/big-bang.cgi
    allowing :all
    denying exit

More demos

I've implemented Netscape "roaming access" using Perl CGIs, let me know if you want more details.

To get a look at the sort of CGIs that I've built for use on CRINOID, here's an overview with explanations and links to the CGIs.

I've also used CRINOID to implement a scheme where students can check their scores in some courses I've taught. It gives them a better idea of how they're doing in the course, and catches those annoying (and damn near inevitable) clerical errors when scores are entered. BTW, they aren't looking at the master score file, but a simplified copy that is transfered from a different machine. I've also used CGIs to implement online quizzes.

Seen enough?

Okay, the distribution is here. I'm also going to try and keep up-to-date information on Perl use on VMS, since that's where you spend much of your effort with CGIs.

Information on Perl 5.6.0 is now available.


This page was last updated on Wed Jan 3 16:53:35 2001 by lane@duphy4.physics.drexel.edu