Gossamer Forum
Home : General : Internet Technologies :

Prevent Someone Overloading and Crashing Apache by refreshing a page repeatedly

Quote Reply
Prevent Someone Overloading and Crashing Apache by refreshing a page repeatedly
If I constantly refresh a CGI script on my server I can easily get the server load up to 8.00 and above. How do I configure apache to stop this happening? If I did it for longer no doubt it would crash.

Your help is much appreciated.
Quote Reply
Re: [crashing] Prevent Someone Overloading and Crashing Apache by refreshing a page repeatedly In reply to
You can set memory usage limits on a vhost basis.

I can't remember the exact command but it is something really simple - a one liner in httpd.conf

Edit:

Found it....

RLimitCPU[/url] Directive[/url] Description: Limits the CPU consumption of processes launched by Apache children Syntax: RLimitCPU number|max [number|max] Default: Unset; uses operating system defaults Context: server config, virtual host, directory, .htaccess Override: All Status: Core Module: core

Takes 1 or 2 parameters. The first parameter sets the soft resource limit for all processes and the second parameter sets the maximum resource limit. Either parameter can be a number, or max to indicate to the server that the limit should be set to the maximum allowed by the operating system configuration. Raising the maximum resource limit requires that the server is running as root, or in the initial startup phase.

This applies to processes forked off from Apache children servicing requests, not the Apache children themselves. This includes CGI scripts and SSI exec commands, but not any processes forked off from the Apache parent such as piped logs.

CPU resource limits are expressed in seconds per process. See also RLimitMEM[/url] Directive[/url] Description: Limits the memory consumption of processes launched by Apache children Syntax: RLimitMEM number|max [number|max] Default: Unset; uses operating system defaults Context: server config, virtual host, directory, .htaccess Override: All Status: Core Module: core

Takes 1 or 2 parameters. The first parameter sets the soft resource limit for all processes and the second parameter sets the maximum resource limit. Either parameter can be a number, or max to indicate to the server that the limit should be set to the maximum allowed by the operating system configuration. Raising the maximum resource limit requires that the server is running as root, or in the initial startup phase.

This applies to processes forked off from Apache children servicing requests, not the Apache children themselves. This includes CGI scripts and SSI exec commands, but not any processes forked off from the Apache parent such as piped logs.

Memory resource limits are expressed in bytes per process. See also RLimitNPROC[/url] Directive[/url] Description: Limits the number of processes that can be launched by processes launched by Apache children Syntax: RLimitNPROC number|max [number|max] Default: Unset; uses operating system defaults Context: server config, virtual host, directory, .htaccess Override: All Status: Core Module: core

Takes 1 or 2 parameters. The first parameter sets the soft resource limit for all processes and the second parameter sets the maximum resource limit. Either parameter can be a number, or max to indicate to the server that the limit should be set to the maximum allowed by the operating system configuration. Raising the maximum resource limit requires that the server is running as root, or in the initial startup phase.

This applies to processes forked off from Apache children servicing requests, not the Apache children themselves. This includes CGI scripts and SSI exec commands, but not any processes forked off from the Apache parent such as piped logs.

Process limits control the number of processes per user.

Note: If CGI processes are not running under userids other than the web server userid, this directive will limit the number of processes that the server itself can create. Evidence of this situation will be indicated by cannot fork messages in the error_log. See also
Quote Reply
Re: [Paul] Prevent Someone Overloading and Crashing Apache by refreshing a page repeatedly In reply to
Just a note, that's only for Apache 2.x, doesn't work in Apache 1.x.

Cheers,

Alex
--
Gossamer Threads Inc.