Skip to content

Auto-configuration based on system resources (CPU/RAM) #5

@iyashjayesh

Description

@iyashjayesh

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions