tags:

views:

1012

answers:

2

The cause was probably that I ran out of disk space, causing everything to work strangely. I will leave this question up anyways in case anyone else has a similar issue.

I have a few PHP scripts that have hung for a long time, but apparently they are not really using much CPU time as they don't get killed. Still they are making it impossible for lighttpd to spawn any more PHP processes as the maximum amount of them has been spawned already.

I'm aware of the set_time_limit that can be used as a function or put into php.ini to control the maximum CPU time a script can run. What I want is to limit all PHP scripts run by my web server (lighttpd) not in CPU time, but clock time.

In case it matters, this is the PHP part from my lighttpd config file.

fastcgi.server = (".php" => ((
 "bin-path" => "/opt/local/bin/php5-cgi",
 "socket" => "/tmp/php.socket" + var.PID,
 "min-procs" => 16,
 "max-procs" => 16,
 "idle-timeout" => 15,
)))

Here is my server-status from lighttpd. You can see that PHP has been running much longer than I bargained for and has caused the server to clog up. Strangely there also seem to be more PHP procs than my max-procs.

legend
. = connect, C = close, E = hard error
r = read, R = read-POST, W = write, h = handle-request
q = request-start,  Q = request-end
s = response-start, S = response-end
388 connections
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhhrhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhhhhhhhhhhhhrhhhhhhhhhhhhhhhhhhhhhhhhrhhhhhhhhhhh
hhhhrhhhhhhhhhhrhrhhhrrhrhhhhhrhhhrhhhhhhrhhhrrrhr
rrhrrrhrhhhhrrhrrhhrrhrrhrrrrrrrrrrrrh

Connections
Client IP:  Read:  Written:  State:  Time:  Host:  URI:  File:
204.16.33.51    0/0 0/0 handle-req 1361 ... (a PHP script)
204.16.33.46    0/0 0/0 handle-req 1420 ... (another PHP script)
... gazillion lines removed ...

Any ideas that could help me set up a configuration that I don't have to constantly babysit would be much appreciated!

A: 

I'm not sure you can do that in lighttpd. You could, however, set up a "spinner" script to periodically check for hung processes and kill them.

Eli
What happens if the 'spinner' script hangs?
Geoffrey Chetwood
You set up a 'spinner-watcher' program. Duh.
Eli
+1  A: 

You're probably best off editing the php.ini file and setting permissions there.

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30     ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 32M      ; Maximum amount of memory a script may consume (8MB)
tj111