Search code examples
cachinggeoserver

GeoWebCache truncates all tiles if disk quota exceeded


I've implemented a web application using GeoServer to provide tile maps. In order to apply caching strategy, I've enabled the embedded GeoWebCache and set tiling page in a PostgreSQL database. The disk quota is set 5 MB and LFU approach to test the truncate behavior on quota limit exceeding. The problem is shown when the caching volumes are more than 5 MB and GeoWebCahe delete all tiles without regarding the "frequency_of_use" of each tile. Is this the expected behavior because I think it should remove least used tiles first.

<!-- geowebcache-diskquota.xml -->

<gwcQuotaConfiguration>
  <enabled>true</enabled>
  <cacheCleanUpFrequency>10</cacheCleanUpFrequency>
  <cacheCleanUpUnits>SECONDS</cacheCleanUpUnits>
  <maxConcurrentCleanUps>2</maxConcurrentCleanUps>
  <globalExpirationPolicyName>LFU</globalExpirationPolicyName>
  <globalQuota>
    <value>5</value>
    <units>MiB</units>
  </globalQuota>
  <quotaStore>JDBC</quotaStore>
</gwcQuotaConfiguration>

and the geowebcache-diskquota-jdbc.xml file:

<gwcJdbcConfiguration>
  <dialect>PostgreSQL</dialect>
  <JNDISource>java:comp/env/jdbc/gwc</JNDISource>
  <connectionPool>
    <driver>org.postgresql.Driver</driver>
    <url>jdbc:postgresql://localhost:5432/gwc</url>
    <username>postgres</username>
    <password></password>
    <minConnections>1</minConnections>
    <maxConnections>10</maxConnections>
    <connectionTimeout>10000</connectionTimeout>
    <maxOpenPreparedStatements>50</maxOpenPreparedStatements>
  </connectionPool>
</gwcJdbcConfiguration>

Solution

  • The disk quota mechanism does not track each single tile, but "tile pages", groups of tiles whose statistics are tracked as a unit, in order to reduce the accounting database size.

    I don't know the details of the implementation to the point of telling you how big a tile page is, but for a tile cache that is potentially hundreds of gigabytes, I would not be surprised if the minimum tracking unit is more than 5MB. If that's the case, then a delete of all the tiles available in a 5MB quota would be very likely.