[Tilecache] tilecache_ mod_python and keep-alive

Christopher Schmidt crschmidt at metacarta.com
Wed May 21 12:53:37 EDT 2008

On Wed, May 21, 2008 at 06:40:26PM +0200, Guillaume Sueur wrote:
> I'm making tests on tilecache performances under various configurations.
> When using mod_python, it appeared that even if requested, the 
> keep-alive http mode was not active.
> ab (Apache bench) makes it obvious :
> ab -v 3 -k -n 1 -c1 myURL

myURL here doesn't actually specify enough information to guess what you
are getting here. I expect that you're putting a URL with an "&" in it,
and as a result, bash or some similar tool is backgrounding the process,
rather than sending the remaining URL parts to the server. The end
result is that the URL that the server gets looks like
"http://localhost/?layers=foo" which is not enough for TileCache to
guess that it is a WMS URL, so it treats it like a TMS metadata request
(the default for anything that doesn't get matched by any service). To
resolve this, the right solution is probably to just put it in single
quotes: 'http://url.com/?foo=bar&bar=baz'
> where it should be Keep-Alive requests : 1
> After few investigations, it came to me that mod_python needed the 
> content_length to be set 
> (http://www.modpython.org/pipermail/mod_python/2004-August/016019.html)
> so I've added
> apacheReq.set_content_length = len(image) to Service.modPythonHandler

This seems a reasonable patch to submit against trunk, but please apply
it equally across the three handlers. 

> on the top of that, the response in ab is a text/xml stuff :
> <?xml version="1.0" encoding="UTF-8" ?>

This problem is described above.

> so, I guess it's quite confusing, so I'll sum it up with few questions :
> - does tilecache.py must be changed with modPythonHandler instead of 
> cgiHandler for mod_python to be used ?

Your apache server needs to be configured for mod_python, following the
instructions in the documentation. There is no tilecache.py included
with TileCache, so I don't know where you got that file, but none should
exist. If removing the file you hae called tilecache.py causes things to
work, then you have not correctly configured mod_python.

> - can you understand why I get different Response Headers and Response 
> when I use ab tool ?

See above.

Christopher Schmidt

More information about the Tilecache mailing list