PHP MapScript hangs or performance degradation

Doug ummmmm at MYREALBOX.COM
Thu Oct 21 15:48:50 PDT 2004


We've got a PHP MapScript application that seems to regularly hang or at least
start responding *very* slowly.

We're now at MapServer/MapScript 4.2.5 (have tried several previous fix
levels), with PHP 4.3.8 (cgi), PostgreSQL 7.4.3, PostGIS 0.8.2, Apache 2.0.51,
Fedora Core 2 SMP (Dual CPU 2GHz P4).

Our MapScript basically does a map->draw(), followed by a couple of
queryByRect() on non-shown layers, manual point->draw()s with custom, numbered
labels, then a map->save().  (Somebody else wrote the code, so I'm trying to
summarize my understanding the best I can in his absence.)

Most of the time, this code seems to work fine and respond decently, although
never "fast" for the particular locations that have lots of individual points
to be numbered.

When things are "normal", I can see one or two active php processes at any
given point in time, none of which are older than the current minute.
According to the "top" command, each such process does seem to use 100% of
(one of?) the CPU while it's running, but that doesn't seem to prevent the
system from otherwise responding normally.

But fairly regularly, the php processes, and their owning httpd processes,
start stacking up and not finishing or going away.  When this happens, queries
to the php scripts start timing out and writing errors to Apache's stderr:

[Thu Oct 21 16:47:30 2004] [error] [client 32.83.226.185] PHP Fatal error:
Maximum execution time of 30 seconds exceeded in
/var/www/html/offender/map.php on line 87

(Line 87 is the map->draw() call)

When this happens, *sometimes* the problem seems to eventually fix itself
where the scripts start responding normally again.  But often the only way
we're able to fix the problem is by stopping and re-starting Apache.

One other interesting symptom is that even when these errors start occurring,
some queries, those that are faster, seem to still work, and at a normal
speed.  The slower ones don't come back at all.

It acts like there's a resource deadlock or bottleneck somewhere, but I can't
imagine a place which would block some queries and not others.

Oh - the layers that we let map->draw() handle are in shapefiles.  The layers
that we queryByRect() are in PostgreS/PostGIS.

So, first, has anyone seen these kinds of symptoms before?  Is there some
obvious problem they indicate?  If not, is there some obvious problem in the
flow/configuration/algorithm I've described?

I appreciate any help the community can offer.  We're currently having to
recycle Apache 3-5 times per day because of these problems.

Doug



More information about the MapServer-users mailing list