ModPerl & Apache related stuff
To reach a broader audience this stuff is in English. Native speakers, please bear with me. This is not my mother tongue.
PostgreSQL has a nice but almost unknown feature called notifications. It allows you to trigger events in external applications by SQL commands. Thus, a print-on-demand system can for example start printing a book as soon as it is paid for without polling the database on a regular basis.
As an example this article implements a mod_perl and Postgres based chat application.
This text actually not related to mod_perl. Suppose you have a WEB application based on a PostgreSQL
database. Over time the database grows and reveals mistakes in the original design because it takes
longer and longer to complete a query. Or perhaps the administrator decided to redesign the indexes
and has forgotten about one that is seldom used. Now, suddenly a certain type of requests has become
unbearable slow. The surprised user presses
Reload again and again. Shortly after that
other parts of the application also show signs of serious slow-down or worse stop to work. Does this
The article talks about how to prevent such situations by cancelling the query running wild in time.
When working with mod_perl, mod_php or other script languages embedded in the Apache httpd the memory
consumption of the whole has to be paid attention. Every now and then people complain on various mailing lists
and forums about their WEB server that works for hours, days or weeks and then suddenly becomes unaccessible.
Even SSH or login on a console times out or takes almost forever. After a
httpd restart everything
works as usual again. These are the symptoms one encounter if the httpd working set does not fit into the
The basic ideas of this article are quite old. I have done similar measurements in 2004 or even earlier. Nevertheless, I think they are worth to be written down.
Modperl worker processes are usually an expensive resource. Hence, locking up such a thing for a long time is undesirable. So, perhaps it's possible to free the apache worker before the request is actually done and handing the client connection over to another more light-weight process?
This article shows how to work around a memory leak in
$r->print based IO for
really large response bodies.
Have you ever asked if it is possible to use mod_proxy in a mod_perl handler to fetch the content of a remote URL? This article explain how to do that.
One can set the text sent to the browser in case the request ends in a HTTP error via
or in Perl via
$r->custom_response($code, $message). But if I need a special
Content-Type header to be passed along, how do I do that? This article explains it.
Perl*Handler can normally trigger HTTP error messages like
404 Not Found by simply
returning something other than
But there is an exception. Filter handlers can only trigger
Apache2::Const::SERVER_ERROR this way.
This article explains why and how to circumvent that limitation.