· benchmark twiki OO
with modperl2
Twiki in Object Oriented
prevents conflits between multiple twiki session opened on an Apache
server with mod_perl. So twiki installation with multiple configuration
becomes possible and stable.
Moreover having multiple configurations working on the same web
server without conflits also allows you to reduce the number of
processes and web server instances running on a single system.
-Each package is trasformed in a class.
-All subs are transformed in methods
and all call to sub are substituted in call to method.
-"sub new" is added to each
package and sets an attribute 'config' to host the address to a hash
$config.
-Main programs in directory bin
declar the variable $config as an address to a hash containing
value of variables (first was global variables) and pointers to objects.
-All global variables are substituted with local variables named as
$config->{<package_name_of_global_var>}->{<global_var_name>}.
The $config variable is an address to a hash where each
key refer to a single twiki global variable.
Example: the global variable "templateDir" of the package "TWiki.pm",
will be replaced with "$config->{TWiki}->{templateDir}".
-In every method, the first operation is fecthing value of attribute 'config' from
$self and saved to a local variable named $config.
All changes of values of $config keys are visible to every methods
using it.
-A new method called init_config has been created to contain
global variable initializations not included in any subroutine ( the
same for code in BEGIN blocks ).
-The .pm files composed of several packages, generate a single file
for each package. For example the file Prefs.pm generates the files
Prefs.pm , Prefs/PrefsCache.pm, Prefs/TopicPrefs.pm.
This package contains
a modified version of TWiki ( beta20040730 version ) transformed
in Object Oriented ( tested on a Red Hat 9 ), it is
composed of:
- the directories ./bin and ./lib
- some configuration files
(NOTE: The name of the url and the name of
configuration files are strictly related )
- lib/alphaPort80twikioo.pm will deploy http://alpha:80/twikioo/bin/view
(twiki code have to be installed in the directory
/home/httpd/twikioo )
- lib/alphaPort80twikioo2.pm will deploy http://alpha:80/twikioo2/bin/view
(twiki code have to be installed in the directory /home/httpd/twikioo ,
pubDir in /home/httpd/twikioo/pub2 and dataDir in /home/httpd/twikioo/data2 and templateDir in /home/httpd/twikioo/templates2 )
The package also
contains :
- modperlizebeta20040730oo.pl and twiki.diff.beta20040730oo
used to "transform" the original twikibeta20040730. You can use them to
transform also your own twiki code as described in this document.
- READMEbeta20040730oo.html (this document)
To use this package you need to:
cd /home/httpd/
cp -r twiki twikioo
cd /home/httpd/twikioo/
rm
–rf bin lib
tar
-xvzf twikibeta20040730oo.tar.gz ./bin ./lib
cd /home/httpd/twikioo/lib
cp alphaPort80twikioo.pm <your server name>Port<your
port>twikioo.pm
To use the second configuration file lib/alphaPort80twikioo2.pm, you need to:
Following this steps
it is possible to make a version of your own twiki (beta20040730) in OO
and run it on a webserver without modperl.
Settings, twiki users, installed plugins will be remain unchanged.
For the plugins verify their prerequisities as described in "requirements to transform
twiki with other plugins".
STEPS
------------------
1 - Copy files twiki.diff.beta20040730oo and modperlizebeta20040730oo.pl
in the parent directory of twiki
2 - Run ./modperlizebeta20040730oo.pl
(The script will apply the patch and will ask confirm before continue,
so you can check the result of patch process)
During transformation the script shows several messagges on standard
output.
At last, it will ask
the informations to create your twiki configuration file:
-host
name
-web
server port
-twiki
SCRIPT_FILENAME setted in your file perl.conf
(You can modify the
file or create a new file follow the steps below )
Estimated time : few
minutes .
3 - Choose A or B :
cd twikioo/bin
perl -pi~ -e 's/\/twiki\//\/twikioo\//' TWikicfg.pm
cp TWikicfg.pm alpahPort80twikioo.pm
#
# FOR twiki oo without global variable
#
ScriptAlias /twikioo/bin/ "/home/httpd/twikioo/bin/"
Alias /twikioo/ "/home/httpd/twikioo/"
<Directory "/home/httpd/twikioo/bin">
Options +ExecCGI
SetHandler cgi-script
Allow from all
</Directory>
<Directory "/home/httpd/twikioo/pub">
Options FollowSymLinks +Includes
AllowOverride None
Allow from all
</Directory>
<Directory "/home/httpd/twikioo/data">
deny from all
</Directory>
<Directory "/home/httpd/twikioo/templates">
deny from all
</Directory>
4 - now you can remove
twiki.patched and twiki.modperlOneKey directories.
Stop and start Apache. Now url http://alpha:80/twiki/bin/view is
available for browsing ( for case B, the url will be http://<hostname>/twikioo/bin/view)
. Twiki pages will appear as usual, but in twiki/bin/testenv page you
can see the new local variable that replaced the global ones, i.e. you
can read "$config->{TWiki}->{pubDir}" instead of "pubDir".
If you have installed
modperl2 , ( included in Linux-Red Hat 9 installation ), you can
transform twiki in Object Oriented using modperl, following described
steps.
STEPS
--------------------------
1 - Apply changes as
described in steps 1,2: transform twiki in Object Oriented
2 -
cd twikioo/lib
perl -pi~ -e 's/\/twiki\//\/twikioo\//' TWikicfg.pm
3 - Add in the configuration file perl.conf
( usually you can find it in /etc/httpd/conf.d/ ) :
LoadModule perl_module modules/mod_perl.so
#
# FOR twiki modperl installation and without global variable
#
Alias /twikioo /home/httpd/twikioo/
<Directory /home/httpd/twikioo/bin>
SetHandler perl-script
PerlHandler ModPerl::Registry::handler
PerlOptions +ParseHeaders
Options +ExecCGI
</Directory>
<Directory "/home/httpd/twikioo/pub">
Options FollowSymLinks +Includes
AllowOverride None
Allow from all
</Directory>
<Directory "/home/httpd/twikioo/data">
deny from all
</Directory>
<Directory "/home/httpd/twikioo/templates">
deny from all
</Directory>
4 - now you can remove
twiki.patched and twiki.modperlOneKey directories.
Stop and start Apache. Now url http://alpha:80/twikioo/bin/view
is available for browsing. Twiki pages will appear as usual, but in
twikioo/bin/testenv page you can see the new local variable that
replaced the global ones, i.e. you can read
"$config->{TWiki}->{pubDir}" instead of "pubDir", and you can read
:
MOD_PERLmod_perl/1.99_07-dev
mod_perl:Used for this script (mod_perl not loaded into Apache) -
mod_perl version 1.9907
When you have a twiki
Object Oriented version without using global variable and installed on
modperl2, you can define multi configuration files.
The name of the url and the name of configuration files are strictly
related; the name of configuration file are composed of:
-the server name
-the server port
-the twiki SCRIPT_FILENAME setted in your file perl.conf and ".pm" .
i.e. url http://alpha:80/twikioo2/bin/view will serch for configuration
file lib/alphaPort80twikioo2.pm.
Following the steps to define multi configurations.
STEPS
--------------------------
1 - Apply all steps described in transform twiki in Object Oriented and install
it with modperl2
2 - Create pub2 data2 and templates2 directory in twikioo directory
:
cd twikioo/lib
cp alphaPort80twikioo.pm alphaPort80twikioo2.pm
perl -pi~ -e 's/\/twikioo\/bin/\/twikioo2\/bin/' alphaPort80twikioo2.pm
perl -pi~ -e 's/\/data/\/data2/' alphaPort80twikioo2.pm
perl -pi~ -e 's/\/pub/\/pub2/' alphaPort80twikioo2.pm
perl -pi~ -e 's/\/templates/\/templates2/' alphaPort80twikioo2.pm
4 - Add in the configuration file perl.conf
( usually you can find it in /etc/httpd/conf.d/ ) :
LoadModule perl_module modules/mod_perl.so
#
# FOR twiki oo with modperl installation and without global variable
#
Alias /twikioo2 /home/httpd/twikioo/
<Directory "/home/httpd/twikioo/pub2">
Options FollowSymLinks +Includes
AllowOverride None
Allow from all
</Directory>
<Directory "/home/httpd/twikioo/data2">
deny from all
</Directory>
<Directory "/home/httpd/twikioo/templates2">
deny from all
</Directory>
Stop and start Apache. Now url http://<hostname>/twikioo2/bin/view
is available for browsing.
This trasformation can
be applied to different versions of twiki, with the same improvement
achieved in beta20040730.
This is possible because modperlizebeta20040730oo.pl it isn't strictly
related to the twiki version ( except for the patch
twiki.diff.beta20040730oo ).
Steps to transform your twiki:
- run modperlizebeta20040730oo.pl
- this will apply the patch twiki.diff.beta20040730oo
- probably this patch won't be able to complete successfully due to
different source code
- in this case you need to reply no at the question "Check patching and
press y to continue: " prompted by the perl script
- check .rej files created in twiki.patched directory
- make patches rejected by editing manually source in twiki.package
directory.
- make the new patch file:
diff -uwbBr twiki twiki.patched > twiki.diff.beta20040730oo
- run again modperlizebeta20040730oo.pl
-now go to step 3 transform twiki in Object
Oriented and install it with modperl2 .
As benchmark program
has been used "ab", a tool for benchmarking Apache HyperText Transfer
Protocol server distibuited with Linux RedHat 9. The command used to
perform 500 http requests was :
ab
-n 500 http://myhost/twiki/bin/view
The following output is the result of "ab" requesting
twiki/bin/view page in a twiki standard installation version
beta20040730.
--------------------------------------------------
This is This is ApacheBench, Version 2.0.40-dev <$Revision: 1.116 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Server Software: Apache/2.0.40
Server Hostname: myhost
Server Port: 80
Document Path: /twiki/bin/view
Document Length: 14455 bytes
Concurrency Level: 1
Time taken for tests: 1721.763662 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 7318500 bytes
HTML transferred: 7227500 bytes
Requests per second: 0.29 [#/sec] (mean)
Time per request: 3443.527 [ms] (mean)
Time per request: 3443.527 [ms] (mean, across all concurrent requests)
Transfer rate: 4.15 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 3387 3442 129.4 3431 6087
Waiting: 3386 3441 128.9 3422 6070
Total: 3387 3442 129.4 3431 6088
Percentage of the requests served within a certain time (ms)
50% 3431
66% 3458
75% 3469
80% 3474
90% 3486
95% 3493
98% 3500
99% 3519
100% 6088 (longest request)
--------------------------------------------------
The following output is the result of "ab" requesting
twikioo/bin/view page in a twiki version beta20040730 Object Oriented
installed on a server mod_perl.
--------------------------------------------------
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.116 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Server Software: Apache/2.0.40
Server Hostname: myhost
Server Port: 80
Document Path: /twikioo/bin/view
Document Length: 14651 bytes
Concurrency Level: 1
Time taken for tests: 1162.40100 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 7416500 bytes
HTML transferred: 7325500 bytes
Requests per second: 0.43 [#/sec] (mean)
Time per request: 2324.080 [ms] (mean)
Time per request: 2324.080 [ms] (mean, across all concurrent requests)
Transfer rate: 6.23 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 2109 2322 619.9 2178 12315
Waiting: 2047 2320 619.1 2177 12315
Total: 2109 2322 619.9 2178 12315
Percentage of the requests served within a certain time (ms)
50% 2178
66% 2228
75% 2292
80% 2335
90% 2498
95% 2828
98% 4718
99% 5141
100% 12315 (longest request)
--------------------------------------------------
Run time of twiki OO with modperl2 are less than standard
installation of about 32,5%.