Free Books / Computers / Practical mod_perl / books


previous page: 1.2.1. Forkingpage up: Practical mod_perl | by Stas Bekman and Eric Choletnext page: 1.2.3. Performance Drawbacks of Forking

1.2.2. CGI Scripts Under the Forking Model

Search

Titles
  • Animals
  • Architecture
  • Arts
  • Business
  • Computers
  • Crafts
  • Finance
  • Flora and Plants
  • Cooking
  • Gardening
  • Health and Healing
  • History
  • Home Improvements
  • Languages
  • New Age
  • Novels
  • Real Estate
  • Reference
  • Religion
  • Science
  • Society
  • Sports
  • Travel
  • Outdoors
  • Site Listing

Discover
  • Find Articles
  • Travel Articles
  • FAQ Help Tutorials






















Description

This section is from the "Practical mod_perl" book, by Stas Bekman and Eric Cholet. Also available from Amazon: Practical mod_perl

One of the benefits of this model is that if something causes the child process to die (e.g., a badly written CGI script), it won't cause the whole service to fail. In fact, only the client that initiated the request will notice there was a problem.

Many free (and non-free) CGI scripts are badly written, but they still work, which is why no one tries to improve them. Examples of poor CGI programming practices include forgetting to close open files, using uninitialized global variables, ignoring the warnings Perl generates, and forgetting to turn on taint checks (thus creating huge security holes that are happily used by crackers to break into online systems).

Why do these sloppily written scripts work under mod_cgi? The reason lies in the way mod_cgi invokes them: every time a Perl CGI script is run, a new process is forked, and a new Perl interpreter is loaded. This Perl interpreter lives for the span of the request's life, and when the script exits (no matter how), the process and the interpreter exit as well, cleaning up on the way. When a new interpreter is started, it has no history of previous requests. All the variables are created from scratch, and all the files are reopened if needed. Although this detail may seem obvious, it will be of paramount importance when we discuss mod_perl.

 

Continue to:

  • prev: 1.2.1. Forking
  • Table of Contents
  • next: 1.2.3. Performance Drawbacks of Forking

Books by Stas Bekman:

Tags

practical mod_perl, modperl, Apache, perl, cgi, html, scalability, free, open source, OSS, squid, high availability, linux, unix, web, www, webserver, admin, book, webmaster, tools, modperl guide, docs, documentation, help, script, eric cholet, stas bekman, performance, speed, choice









TOP
previous page: 1.2.1. Forkingpage up: Practical mod_perl | by Stas Bekman and Eric Choletnext page: 1.2.3. Performance Drawbacks of Forking

© 2007 StasoSphere

[ Privacy Policy ] [ Terms of Use ] [ About Us ] [ Search ]

Last modified Fri Jul 18 13:32:17 2008