-
-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: thread autoscaling #1266
base: main
Are you sure you want to change the base?
feat: thread autoscaling #1266
Conversation
# Conflicts: # frankenphp.c # frankenphp.go # php_thread.go # worker.go
# Conflicts: # frankenphp.go
I removed the POST and DELETE admin endpoints for now, we can add them back in if needed. |
# Conflicts: # thread-worker.go # watcher_test.go
Is this one ready for prime time? |
# Conflicts: # phpmainthread.go # phpthread.go
Yes, I think this one should be good to go for an initial implementation via the I might create a separate project with integration tests and some extensions/framework at some point so there's more confidence before releases. |
I created a small testing repo with Laravel, since it's the PHP Framework I'm most familiar with. Right now it just tests a few of the most popular extensions in The only issue I found so far is that calling On worker restarts all threads are first stopped, which prevents the crashing. It's just problematic if |
Alright I think this is ready to merge. Not sure why watcher installation is failing right now in asan and msan |
I originally wanted to just create a PR that allows adding threads via the admin API, but after letting threads scale automatically, that PR kind of didn't make sense anymore by itself.
So here is what this PR does:
It adds 4 Caddy admin endpoints
Additionally, the PR also introduces a new directive in the config:
max_threads
.If it's bigger than
num_threads
, worker and regular threads will attempt to autoscale after a request on a few different conditions:This is all still a WIP. I'm not yet sure if
max_threads
is the best way to configure autoscaling or if it's even necessary to have the PUT/DELETE endpoints. Maybe it would also make sense to determine max_threads based on available memory.I'll conduct some benchmarks showing that this approach performs better than default settings in a lot of different scenarios (and makes people worry less about thread configuration).
In regards to recent issues, spawning and destroying threads would also make the server more stable if we're experiencing timeouts (not sure yet how to safely destroy running threads).