Litmus:mod perl: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
 
No edit summary
Line 1: Line 1:
== mod_perl Developers' Guide ==
== mod_perl Developers' Guide ==
As of August 2006, Litmus uses mod_perl to improve performance. Typically, normal CGI scripts must be compiled by the perl interpreter for each http request. Furthermore, every request requires that perl load and compile all the perl modules Litmus uses, connect to the database, go through the Template Toolkit's initialization routines, and all sorts of other activities before Litmus even gets started processing a particular request. mod_perl performs this initialization step only once--at web server startup time--and runs the script within the context  of an already running perl interpretor.
The upside of supporting mod_perl is the performance benefit. Initial benchmarking with a mod_perl enabled version of Litmus showed performance improvements on the order of 2X-8X depending on what script is measured. mod_perl also reduces load on the web server, allowing it to process more requests.
The downside is that code needs to be written with mod_perl in mind. Below are a few notes on mod_perl support as it relates to Litmus.
See also the [http://perl.apache.org/docs/1.0/guide/porting.html mod_perl porting guidelines] for further details.
=== Web Server Restarting / Module Persistence ====
Under mod_perl, modules are not reloaded on each http request. This means that if you update Litmus or modify a .pm file within the Litmus tree, those changes will not be picked up until the web server is restarted.
Litmus developers may prefer to use a 'touch file,' a special file that, when touched, causes the web server to reload modules. The use of a touch file is documented in the mod_perl documentation. Otherwise, a simple 'apachectl restart' as root will suffice.
On rodan, members of group 'litmus' may trigger a web server restart with the command 'litmus-restart'. Use with extreme caution and fix any errors immediately.
=== Global Variables ===
Another issue to be aware of when coding for mod_perl is global variables. Unless measures are taken, global variables will not be automatically reset between requests. See the [http://perl.apache.org/docs/1.0/guide/porting.html mod_perl porting guidelines] for more information.
Litmus provides a special object cache that ensures that global variables stored in the cache will be destroyed after each request. This cache is used for global objects such as the current CGI.pm or Template.pm instance. These variables may be accessed through Litmus.pm as before. Scripts can also use the object cache to store global data if needed (although good design dictates that globals should be avoided whenever possible). Information on how to do so can be found in Litmus.pm.
314

edits

Navigation menu