Skip to content

Make seeder thread pool sizes configurable (fixes #1429)#1535

Open
petersmythe wants to merge 2 commits into
GeoWebCache:mainfrom
petersmythe:fix/configurable-seeder-pool-size
Open

Make seeder thread pool sizes configurable (fixes #1429)#1535
petersmythe wants to merge 2 commits into
GeoWebCache:mainfrom
petersmythe:fix/configurable-seeder-pool-size

Conversation

@petersmythe
Copy link
Copy Markdown
Contributor

@petersmythe petersmythe commented May 28, 2026

Summary

Makes the GeoWebCache seeder thread pool sizes configurable via geowebcache.xml (primary configuration) with environment variable overrides for Docker/cloud deployments, as requested in #1429.

Previously, the core pool size (16) and max pool size (32) were hardcoded in Spring XML with no way to override them without modifying the application context.

Configuration

Primary: geowebcache.xml

<gwcConfiguration>
  ...
  <seederCorePoolSize>24</seederCorePoolSize>
  <seederMaxPoolSize>64</seederMaxPoolSize>
  ...
</gwcConfiguration>
Element Description Default
seederCorePoolSize Core thread pool size for seeding tasks 16
seederMaxPoolSize Maximum thread pool size for seeding tasks 32

Override: Environment variables

For Docker/cloud deployments, the XML configuration can be overridden:

Override Overrides
GWC_SEEDER_CORE_POOL_SIZE seederCorePoolSize
GWC_SEEDER_MAX_POOL_SIZE seederMaxPoolSize

Precedence: Environment variable / system property (-D) → geowebcache.xml → hardcoded default (16/32).

Changes

  • ServerConfiguration: Added getSeederCorePoolSize() / getSeederMaxPoolSize() default interface methods.
  • GeoWebCacheConfiguration: Added seederCorePoolSize / seederMaxPoolSize fields (POJO for geowebcache.xml).
  • geowebcache.xsd: Added <seederCorePoolSize> and <seederMaxPoolSize> schema elements.
  • geowebcache.xml (example): Added commented-out example.
  • geowebcache-core-context.xml: Bean wiring now reads from gwcXmlConfig via SpEL, falling back to 16/32.
  • SeederThreadPoolExecutor: Added resolvePoolSize() for env var override with validation (invalid values fall back to defaults, core > max auto-adjusts).
  • New SeederThreadPoolExecutorTest with 9 test cases.
  • Documentation updated in production/index.rst.

Backward Compatibility

  • The Spring XML bean definitions now read from the configuration object but fall back to 16/32 if not set — existing deployments without seederCorePoolSize/seederMaxPoolSize in their geowebcache.xml continue to work unchanged.
  • SeederThreadLocalTransferExecutor (GeoServer subclass) works without modification.
  • No changes to the constructor signature.

Testing

  • 9 unit tests covering: defaults, system property override, partial override, invalid values (non-numeric, negative, zero), whitespace handling, trimming, and corePoolSize > maxPoolSize adjustment.
  • Manually tested in Docker with GeoServer 3.0.x nightly — confirmed 24 threads active matching GWC_SEEDER_CORE_POOL_SIZE=24 via jcmd Thread.print.

Supersedes

This replaces the approach in #1430 which used Spring property placeholders in the XML. That approach had test failures and didn't meet the requirement of being configurable outside of application contexts.

Closes #1429

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Makes the GeoWebCache seeder thread pool core/max sizes configurable at the Java level (system property → env var → constructor default), so they can be overridden without editing Spring XML. The constructor signature is unchanged, preserving backward compatibility with SeederThreadLocalTransferExecutor and existing wirings.

Changes:

  • Add GWC_SEEDER_CORE_POOL_SIZE / GWC_SEEDER_MAX_POOL_SIZE constants and a resolvePoolSize helper in SeederThreadPoolExecutor, with auto-adjustment when core > max and a startup info log of the effective sizes.
  • New SeederThreadPoolExecutorTest covering defaults, overrides, invalid/blank/negative values, whitespace trimming, and core-exceeds-max adjustment, using the existing PropertyRule test rule.
  • Documentation section added under production/index.rst describing the new properties, precedence, and the auto-adjust behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
geowebcache/core/src/main/java/org/geowebcache/seed/SeederThreadPoolExecutor.java Adds runtime resolution of core/max pool sizes from system properties/env vars with fallback to constructor defaults.
geowebcache/core/src/test/java/org/geowebcache/seed/SeederThreadPoolExecutorTest.java New unit tests exercising default, override, invalid, and core>max scenarios via PropertyRule.
documentation/en/user/source/production/index.rst Documents the new configuration properties, precedence, and adjustment behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread geowebcache/core/src/main/java/org/geowebcache/seed/SeederThreadPoolExecutor.java Outdated
Comment thread geowebcache/core/src/main/java/org/geowebcache/seed/SeederThreadPoolExecutor.java Outdated
@petersmythe petersmythe force-pushed the fix/configurable-seeder-pool-size branch from 45234f5 to 1a12d25 Compare May 28, 2026 15:21
@aaime
Copy link
Copy Markdown
Member

aaime commented May 28, 2026

GeoWebCache has a configuration file, it's geowebcache.xml, new configurations should go in there... an env variable override makes some sense too, but as an override, not straight configuration. Most of the GWC configuration is in that XML file, we should not create a parallel configuration system just because it's convenient to code.

@petersmythe petersmythe marked this pull request as draft May 28, 2026 15:25
@petersmythe
Copy link
Copy Markdown
Contributor Author

GeoWebCache has a configuration file, it's geowebcache.xml, new configurations should go in there... an env variable override makes some sense too, but as an override, not straight configuration. Most of the GWC configuration is in that XML file, we should not create a parallel configuration system just because it's convenient to code.

Thank you, of course it should. I will rework.

@petersmythe petersmythe force-pushed the fix/configurable-seeder-pool-size branch from 1a12d25 to d6bc15b Compare May 28, 2026 15:59
petersmythe pushed a commit to petersmythe/geoserver that referenced this pull request May 28, 2026
Add documentation for GWC_SEEDER_CORE_POOL_SIZE and GWC_SEEDER_MAX_POOL_SIZE
environment variables / system properties that allow configuring the seeder
thread pool size.

- Add new 'Seeder thread pool size' section to geowebcache/seeding.md
- Add entries to the Application Properties reference table

Accompanies GeoWebCache/geowebcache#1535
@petersmythe petersmythe requested a review from Copilot May 28, 2026 16:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread geowebcache/core/src/main/java/org/geowebcache/seed/SeederThreadPoolExecutor.java Outdated
…v vars

Allow GWC_SEEDER_CORE_POOL_SIZE and GWC_SEEDER_MAX_POOL_SIZE to be
specified as Java system properties or OS environment variables, with
system properties taking precedence. Falls back to the Spring XML
constructor arguments (16/32) when not set or invalid.

Invalid values (non-numeric, zero, negative) are logged as warnings
and the defaults are used. If corePoolSize exceeds maxPoolSize after
resolution, maxPoolSize is automatically adjusted upward to match.

Includes unit tests and documentation updates.

Closes GeoWebCache#1429
@petersmythe petersmythe force-pushed the fix/configurable-seeder-pool-size branch from d6bc15b to b57d1f9 Compare May 28, 2026 16:59
@petersmythe petersmythe requested a review from Copilot May 28, 2026 17:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread geowebcache/core/src/main/java/org/geowebcache/seed/SeederThreadPoolExecutor.java Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@petersmythe petersmythe marked this pull request as ready for review May 28, 2026 17:49
@petersmythe
Copy link
Copy Markdown
Contributor Author

Ready and tested again. Thanks for the feedback.

petersmythe pushed a commit to petersmythe/geoserver that referenced this pull request May 28, 2026
Add documentation for GWC_SEEDER_CORE_POOL_SIZE and GWC_SEEDER_MAX_POOL_SIZE
environment variables / system properties that allow configuring the seeder
thread pool size.

- Add new 'Seeder thread pool size' section to geowebcache/seeding.md
- Add entries to the Application Properties reference table

Accompanies GeoWebCache/geowebcache#1535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

maxPoolSize and maxThreadSize should be configurable

4 participants