Skip to content

Conversation

@AlliBalliBaba
Copy link
Contributor

@AlliBalliBaba AlliBalliBaba commented Nov 7, 2025

Currently all workers compete for all threads on scaling, this PR allows setting an absolute limit per-worker.

worker "/worker1.php" {
  num 4
  max_threads 8
}

worker "/worker2.php" {
  num 4
  max_threads 4
}

Can be useful:

Copy link
Contributor

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

This PR introduces per-worker max_threads configuration to allow setting absolute thread limits for individual workers, preventing them from consuming all available threads during scaling. This is useful for isolating worker pools, managing extensions, and running multiple domains with separate thread limits.

  • Adds maxThreads field to worker configuration and corresponding validation logic
  • Updates scaling logic to respect per-worker thread limits
  • Adds comprehensive test coverage for thread calculation scenarios with worker-specific limits

Reviewed Changes

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

Show a summary per file
File Description
worker.go Adds maxThreads field to worker struct and implements logic to prevent scaling beyond per-worker limit
scaling.go Updates upscaling logic to check and enforce per-worker max thread limits
phpmainthread_test.go Adds test cases for thread calculation with per-worker max_threads configurations
options.go Adds WithWorkerMaxThreads option function for configuring worker max threads
frankenphp.go Implements validation and calculation logic for worker max_threads in relation to global limits
caddy/workerconfig.go Adds Caddyfile parsing support for max_threads directive in worker configuration
caddy/app.go Wires up worker max_threads configuration to FrankenPHP options
caddy/admin_test.go Updates test to verify auto-scaling respects per-worker max_threads limits

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

@dunglas
Copy link
Member

dunglas commented Nov 17, 2025

Could you please rebase @AlliBalliBaba?

@dunglas dunglas merged commit 0b2d3c9 into main Nov 18, 2025
23 of 24 checks passed
@dunglas dunglas deleted the feat/per-worker-max-threads branch November 18, 2025 10:55
@dunglas
Copy link
Member

dunglas commented Nov 18, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants