[Chameleon] performance of drawmap.php

Paul Spencer pagameba at magma.ca
Tue Jun 1 09:55:51 EDT 2004


Bart,

good question :)  I still have it on my list to look at this problem. 
The differences boil down to:

The drawmap method does the following:

1. start apache process
2. load php
3. load mapscript
4. start session
5. load map object
6. execute a bunch of php code
7. draw map

The mapserv cgi method does the following

1. start apache process
2. start mapserv cgi
3. load map object
4. draw map

I suspect that the load map and draw map steps are roughly the same 
within a couple of milliseconds.  Starting apache and loading 
mapscript/mapserv should be roughly the same.

So the difference lies in:

1. loading php
2. starting the session
3. execute a bunch of php code

The code between loading the map object and actually producing a map 
image adds some overhead (but I would be suprised if it is more than 50 ms).

Note that if the web stress tool does simulatenous requests, they will 
all stall because php does session locking.  I had originally intended 
to access the session in some read-only mode that would not lock it, 
this is difficult to do because we actually trap drawing errors and put 
them into the session so that the user can see why layers failed to draw.

The reason why we use drawmap is to delay drawing the map until the page 
has started loading.  This increases apparent performance while 
decreasing overall performance by requiring a second process to be 
started to draw the map.  Because of the session locking, the drawmap 
request cannot be performed until after the page has been sent to the 
browser and the main thread has exited.  Drawing the map as part of the 
execution of the application *could* speed up the final product 
significantly, but in general I think it would result in a slower 
feeling application, especially if you are using WMS sources.  At least 
this way, the page loads reasonably quickly and you are left waiting for 
the image.

Alternatives ...

1. add a method of requesting the map directly by giving the 
mapdhtmlwidget a mapserv cgi and passing it the path to the map file

- pros: this is probably the absolute fastest way to get the image 
without actually drawing it while the page loads
- cons: this is a security risk because it exposes absolute paths. 
There may be some ways to limit the security risk, esp on linux systems
       : lose the ability to provide feedback to the user on why map 
draws failed.

2. add an attribute that would cause the mapdhtmlwidget to render the 
image during execution of the application.  I think most of the code to 
support this is in the mapdhtmlwidget, it would just need a bit of 
tweaking and a new attribute.
- pros: the overall page load time would probably decrease
       : would maintain the ability to report errors to the user
- cons: the responsiveness of the application would be worse

3. write a stripped down drawmap.php, removing some of the extra code
- pros: maintain existing code in mapdhtmlwidget, maintain 
responsiveness of application
- cons: minimal speed benefit likely

Any comments, discussion and more ideas welcome ... personally, I like 
option 1 if security is not an issue (or there are work arounds)

Cheers,

Paul

bartvde at xs4all.nl wrote:

> Hi list,
> 
> I have done a test with the Microsoft Web Stress test tool by requesting
> an image to drawmap.php, and requesting the same image to Mapserver CGI
> directly. I only have one visible layer in my application. All tests
> performed on the server itself (localhost), so no network traffic
> involved.
> 
> These are the results:
> 
> directly to Mapserver WMS:
> 136 hits in 1 minute: average is 438.86 ms.
> 
> using drawmap.php:
> 42 hits in 1 minute: average is 1409.50 ms.
> 
> Why is there such a big performance loss in this step? This seems to be
> the largest performance bottleneck in Chameleon.
> 
> Best regards,
> Bart
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 

-- 
  -----------------------------------------------------------------
|Paul Spencer                           pspencer at dmsolutions.ca   |
|-----------------------------------------------------------------|
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
  -----------------------------------------------------------------



More information about the Chameleon mailing list