[Speedycgi-users] Explanation of speedy groups
Brought to you by:
samh
|
From: Sam H. <sa...@da...> - 2002-09-19 19:25:17
|
From the upcoming release....
USING GROUPS
The group feature in SpeedyCGI can be used to help reduce the amount of
memory used by the perl interpreters. When groups are not used (ie when
group name is "none"), each perl script is given its own set of perl
interpreters, separate from the perl interpreters used for other
scripts. In SpeedyCGI each perl interpreter is also a separate unix
process.
When grouping is used, perl interpreters are put into a group. All perl
interpreters in that group can run perl scripts in that same group. What
this means is that by putting all your scripts into one group, there
could be one perl interpreter running all the perl scripts on your
system. This can greatly reduce your memory needs when running lots of
different perl scripts.
SpeedyCGI group names are entities unto themselves. They are not
associated with Unix groups, or with the Group directive in Apache.
Group names are created by the person running SpeedyCGI based on their
needs. There are two special group names "none" and "default". All other
group names are created by the user of SpeedyCGI using the Group option
described in the section on "OPTIONS".
If you want to use the maximum amount of grouping possible (ie all
scripts in the same interpreter), then you should always use the group
name "default". When you do this, you will get the fewest number of perl
interpreters possible. Each perl interpreter will be able to run any of
your perl scripts.
Although using group "default" for all scripts results in the most
efficient use of resources, it's not always possible or desirable to do
this. You may want to use other group names for the following reasons:
* To isolate misbehaving scripts, or scripts that don't work in groups.
Some scripts cannot work in groups. When perl scripts are grouped
together they are each given their own unique package name - they
are not run out of the "main" package as they normally would be. So,
for example, a script that explicitly uses "main" somewhere in its
code to find its subroutines or variables probably won't work in
groups. In this case, it's probably best to run such a script with
group "none", so it is compiled and run out of package main, and
always given its own interpreter.
Other scripts may make changes to included packages, etc, that may
break other scripts running in the same interpreter. In this case
such scripts can be given their own group name (like group name
"pariah") to keep them away from other scripts that they are
incompatible with. The rest of your scripts can then run out of
group "default". This will ensure that the "pariah" scripts won't
run within the same interpreter as your other scripts.
* To pass different perl or SpeedyCGI parameters to different scripts.
The first script to start up in a group sets the perl and SpeedyCGI
parameters used from then on for all scripts in that group. You may
want to use separate groups to create separate policies for
different scripts.
Say you have an email application that contains ten perl scripts,
and since the common perl code used in this application has a bad
memory leak, you want to user a MaxRuns setting of 5 for all of
these scripts. You then want all your other scripts to run in a
separate group with a normal MaxRuns policy. What you can do is edit
the ten email scripts, and at the top, put in the line:
#!/usr/bin/speedy -- -gmail -r5
In the rest of your perl scripts you can use:
#!/usr/bin/speedy -- -g
What this will do is put the ten email scripts into a group of their
own (named "mail") and give them all the default MaxRuns value of 5.
All other scripts will be put into the group named "default", and
this group will have the normal MaxRuns setting.
|