Reduce sleep between reading server logs to improve performance for heavy-logging Laravel application using a stderr/stdout logging driver. #902
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.
Hi.
Since the issue has been closed and there is no further activity on #724 , I thought I'd give a proposal on a minimal fix that doesn't break any current applications.
This change makes it possible to change the duration of the usleep that happens after reading the server output pipes in InteractsWithServers. Most users will not need to configure this parameter, but Laravel applications with busy stdout/stderr pipes might.
The change also proposes changing the default from 500ms to 10ms, as 500ms is a potentially large sleep where the server may be trying to write to full pipes.
Benchmarks for a heavily logging Laravel application
I initialized a Laravel application, and installed octane and FrankenPHP. I then added the following endpoint to the api routes.
Default Laravel Octane setup
With the default setup, when working it with 2 connections over a timespan of a minute, I get the following results:
Logging with LOG_CHANNEL=stderr and 500ms sleep
I then add the enviroment variable
LOG_CHANNEL=stderr
with the current laravel/octane^2.0 500ms sleepNotice the significant drop in throughput and increase in latency.
Logging with LOG_CHANNEL=stderr and 10ms sleep
Now I introduce the changes in this PR and test again
As the numbers tell, the application, with these proposed changes, are now back to the numbers of the default application logger.