Conversation
dunglas
approved these changes
Mar 17, 2025
Member
|
Thanks! |
Member
|
We must update the docs to mention this new feature. |
Contributor
Author
|
@dunglas 👍 I'll create a PR when I get to it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a simple timeout option for waiting too long for a PHP thread to accept a request. This helps the server recover faster during latency spikes by not allowing an endless accumulation of queued requests. It's similar to reverse-proxy timeouts and originally inspired by this discussion and another one I can't find anymore.
max_wait_timeis not enabled by default, but it might make sense to equate this to the php.inimax_execution_time.performance impact
The performance impact is ~0 if the
max_wait_timeoption is not enabled (selecting over a nil channel is free).If the option is enabled, there's a slight performance degradation in the optimized 'Hello World' (135000 RPS -> 125000 RPS 20 CPU cores). Real-live applications shouldn't feel this degradation though. In go 1.22 enabling the option would even increase performance, but go 1.23 changed it's timer implementation a bit, which apparently traded some efficiency for precision.
other considerations
This is only a first step towards making the server more resilient. I've thought of other ways to time out threads and came to the conclusion that this is probably best done in combination with the 'scaling' logic. The same goroutine that stops idle threads might also kill stuck threads or restart threads that reach memory limits.
docs
Docs should probably be added after another release to avoid them going up before the actual feature