Skip to content
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

Allow Customization of waitUntilReady Timeout via Environment Variable #1917

Open
ttsuru opened this issue Mar 3, 2025 · 2 comments
Open
Labels

Comments

@ttsuru
Copy link

ttsuru commented Mar 3, 2025

Description:

In the PHP-FPM runtime, when a request times out, PHP-FPM restarts. However, in some cases, the restart itself times out, leading to a state where the runtime cannot be started anymore.

By default, PHP-FPM is expected to start within 5 seconds. However, when using Symfony with multiple extensions and opcache.preload, this 5-second limit may not be sufficient.

I found that increasing the waitUntilReady timeout to 8 seconds resolved the issue.

Would it be possible to allow the waitUntilReady timeout to be customized via an environment variable?
If a PR is needed, please let me know.

Thanks for the great project!

@ttsuru ttsuru added the bug label Mar 3, 2025
@mnapoli
Copy link
Member

mnapoli commented Mar 3, 2025

Wow 8 seconds is huge. But if that's necessary and it actually works, I think it's hard to argue against this suggestion.

👍 to add an environment variable to configure that.

@ttsuru
Copy link
Author

ttsuru commented Mar 3, 2025

I understand that AWS Lambda has a 10-second cold start limit, so the startup time must remain within this constraint.

I am using the ap-northeast-1 region, where the Init Duration was 2644.02 ms during a normal cold start. However, when a timeout occurred and PHP-FPM restarted, the restart attempt failed, taking 7074.87 ms.

I am unsure why PHP-FPM restart takes significantly longer than the initial startup.

XXX The PHP script timed out. Bref will now restart PHP-FPM to start from a clean slate and flush the PHP logs.
--
Timeouts can happen for example when trying to connect to a remote API or database, if this happens continuously check for those.
If you are using a RDS database, read this: https://bref.sh/docs/environment/database.html#accessing-the-internet
NOTICE: Terminating ...
NOTICE: exiting, bye-bye!
XXX Task timed out after 28.55 seconds
END RequestId: XXX
REPORT RequestId: XXX	Duration: 28547.96 ms	Billed Duration: 30645 ms	Memory Size: 512 MB	Max Memory Used: 216 MB	Init Duration: 2644.02 ms
LOGS	Name: cloudwatch_lambda_agent	State: Already subscribed	Types: [Platform]
--
Fatal error: RuntimeException: Error while starting PHP-FPM: Timeout while waiting for PHP-FPM socket at /tmp/.bref/php-fpm.sock in /var/task/vendor/bref/bref/src/FpmRuntime/Main.php:39
The function failed to start. AWS Lambda will restart the process, do not be surprised if you see the error message twice.
--
EXTENSION	Name: cloudwatch_lambda_agent	State: Ready	Events: [INVOKE, SHUTDOWN]
INIT_REPORT Init Duration: 7074.87 ms	Phase: invoke	Status: error	Error Type: Runtime.UnknownReason
START RequestId: XXX Version: $LATEST
Unknown application error occurredRuntime.UnknownReason
END RequestId: XXX
REPORT RequestId: XXX	Duration: 7592.93 ms	Billed Duration: 7593 ms	Memory Size: 512 MB	Max Memory Used: 184 MB
LOGS	Name: cloudwatch_lambda_agent	State: Already subscribed	Types: [Platform]
Fatal error: RuntimeException: Error while starting PHP-FPM: Timeout while waiting for PHP-FPM socket at /tmp/.bref/php-fpm.sock in /var/task/vendor/bref/bref/src/FpmRuntime/Main.php:39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants