[Tilecache] [SUMMARY] Windows, MetaTiling, and Disk cache locking

Shawn Gervais project10 at project10.net
Fri May 29 00:45:07 EDT 2009


I was having trouble with metatiling and excessive requests to my
backend WMS on Windows, and with Chris' help, I tracked it down to the
locking behavior implemented by the Disk cache. I'll try to summarize
the problem and solution, in case anyone else runs into the same issue
later.

My setup: Windows 2003, Apache 2.2.11, mod_fcgid, TileCache 2.10,
mod_python, Python 2.5, mapserver trunk WMS. Because I'm using
metatiling I also have PIL installed. My TileCache instance is accessed
through a WMS Layer in an OpenLayers 2.7 application.

The problem: I noticed, by looking at the Apache request log, that
multiple identical requests were being issued by TileCache to MapServer,
and that this only happened when metatiling was used.

As a result, my WMS was getting about 3 times the load that it should
have been.

The cause: On Windows, the Disk cache was failing to acquire exclusive
locks properly. It seems a race condition existed, in which multiple
requests coming in quickly from OL which fell within the same metatile
boundary, would all acquire the same lock. Then, each would hit the 
backend WMS and request a full metatile render.


My workaround: I added an "os.path.exists" before os.makedirs in 
Disk.py, to mimic the expected behavior of os.makedirs alone -- namely, 
that os.makedirs on an existing path should throw OSError. With this 
change, the locking appears to work correctly and only the first request 
for a subtile of a metatile will actually hit the backend WMS.

-Shawn



More information about the Tilecache mailing list