Add automatic configuration of worker pool parameters based on system resources and workload profiles to provide better defaults and reduce configuration burden.
Problem
Currently users must manually configure MinWorkers, MaxWorkers, and QueueSize without knowing optimal values for their system. This leads to:
- Guesswork during initial setup
- Suboptimal defaults for different hardware
- Need for manual tuning on each deployment environment
Proposed Solution
Add auto-configuration options that detect system resources and set sensible defaults:
// Simple profile-based approach
pool, err := adaptivepool.New(
adaptivepool.WithAutoConfig(adaptivepool.ProfileAPIServer),
)
// Advanced system-aware config
pool, err := adaptivepool.New(
adaptivepool.WithSystemAwareConfig(adaptivepool.SystemAwareConfig{
WorkloadType: adaptivepool.IOBound,
TargetLatencyMs: 500,
AvgJobMemoryBytes: 50 * 1024,
MemoryLimitPercent: 0.2,
}),
)
Suggested Workload Profiles
ProfileAPIServer (I/O bound):
- MinWorkers:
NumCPU * 2
- MaxWorkers:
NumCPU * 10
- QueueSize:
MaxWorkers * 20
ProfileCPUIntensive:
- MinWorkers:
NumCPU
- MaxWorkers:
NumCPU * 2
- QueueSize:
MaxWorkers * 5
ProfileBatchProcessor:
- MinWorkers:
NumCPU * 2
- MaxWorkers:
NumCPU * 4
- QueueSize:
MaxWorkers * 50
Auto-detection Capabilities
- CPU cores via
runtime.NumCPU()
- Available memory via
runtime.MemStats
- Container limits (Docker/K8s cgroups)
- Calculate queue size based on memory constraints
Related Discussion
This feature was requested in LinkedIn discussion about queue sizing strategies and would complement the existing adaptive scaling behavior.
Open Questions
- Should we provide a
SuggestConfig() method based on runtime metrics?
- How to handle heterogeneous clusters (different node sizes)?
- Should profiles be extensible by users?
Add automatic configuration of worker pool parameters based on system resources and workload profiles to provide better defaults and reduce configuration burden.
Problem
Currently users must manually configure
MinWorkers,MaxWorkers, andQueueSizewithout knowing optimal values for their system. This leads to:Proposed Solution
Add auto-configuration options that detect system resources and set sensible defaults:
Suggested Workload Profiles
ProfileAPIServer (I/O bound):
NumCPU * 2NumCPU * 10MaxWorkers * 20ProfileCPUIntensive:
NumCPUNumCPU * 2MaxWorkers * 5ProfileBatchProcessor:
NumCPU * 2NumCPU * 4MaxWorkers * 50Auto-detection Capabilities
runtime.NumCPU()runtime.MemStatsRelated Discussion
This feature was requested in LinkedIn discussion about queue sizing strategies and would complement the existing adaptive scaling behavior.
Open Questions
SuggestConfig()method based on runtime metrics?