httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Albert <>
Subject Re: [users@httpd] Make apache sleep
Date Tue, 23 Oct 2007 17:18:53 GMT
Jim Albert wrote:
> For the purposes of testing a heavy load situation, I'd like to 
> configure one of my apache web servers to intentionally respond slow to 
> a request.
> Is anyone aware of some type of apache sleep or delay configuration that 
> will easily allow me to configure this? For example, tell apache to wait 
> 10 seconds before responding to any request.

Thanks to all who responded. I was hoping apache already had a 
configuration built in to do this. Instead of turning a variety of pages 
into dynamic pages in order to insert a sleep, I ended up writing an 
apache module and configured it with PerlInitHandler. This worked out 
well as I could configure it to just slow for my ip address without 
affecting anyone else. I could also easily apply it to all requests or a 
particular request via the <Location> tag.

In conf.d/perl.conf add this line:
PerlInitHandler MyDelay

Contents of are as follows:

package MyDelay;

# This package can be used in conjunction with a
# PerlInitHandler directive to slow down a connection
# based on an ip address

# Example: set in perl.conf
# To slow down a particular request
#<Location /delay_test.html>
#   PerlInitHandler MyDelay
# or outside of any Location, File, etc to slow down all requests
#  PerlInitHandler MyDelay

use strict;
use Apache2::RequestRec;
use Apache2::Const;             # for OK
use Apache2::Connection;		# for remote_ip

sub handler
    my $r = shift;

    $c = $r->connection;
    $ip_addr = $c->remote_ip;
    if ($ip_addr eq "my ip address")
       print STDERR ("in MyDelay:handler\n");
       print STDERR ("ip_addr = $ip_addr\n");
       sleep (30);

    return OK;


Jim Albert

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message