-
-
Notifications
You must be signed in to change notification settings - Fork 34
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(frankenphp-symfony): add kernel reboot strategy #166
base: main
Are you sure you want to change the base?
feat(frankenphp-symfony): add kernel reboot strategy #166
Conversation
Hm, does this not offset the benefits of the worker mode? |
@phramz that sounds like an issue that some services may forgot to implement the KernelResetInterface. In the worker mode the kernel should be keep bootet and only services resetted. |
@Rainrider Since the reboot takes place between requests, it will take some extra time until the worker is able the handle the next request which might impact performance in case all workers are busy (e.g. under high load). This should not impact other "benefits" of the worker mode. The kernel reboot mode defaults to @alexander-schranz which |
The https://github.com/symfony/symfony/blob/7.1/src/Symfony/Contracts/Service/ResetInterface.php (service tag kernel.reset) is responsible that a Symfony Service clean it self up without have to reboot the Kernel. If you have problems with session it may an issue with the sessions you may access the session differently then over the Symfony objects? Symfony itself does there the cleanup of the session in its Listeners. |
@alexander-schranz I guess that might be the general root cause for the issues. For me it pretty much looks related to Baldinof/roadrunner-bundle#116 Unfortunately I didn't have enough time to do perform an in the depth debugging of all components being involved, so I went for a kernel reboot between requests (luckily RR supported it) that solved it for me. |
@phramz is there any benefit left other than not having to pay start-up costs for the worker itself? Please excuse my lack of knowledge in this regard. Depending on your answer it might be better to just disable worker mode instead. |
@Rainrider The biggest advantage of using worker-mode is the performance gain. This is due to request hit a warm (running) application. That eliminates expensive overhead like parsing, class loading, etcpp. |
Class loading and parsing is what the The easiest way to find where you need to add a Keep in mind if you use example async messenge:consume via Symfony Messenger you need to take care of the same things via the ResetInterface, to make sure the services are between 2 consumed messages correctly reseted. |
I think it could be interesting to have the For example if ($this->kernel instanceof RebootableInterface && ('on_error' === $this->kernelReboot) && $sfResponse->getStatusCode() >= 500) {
$this->kernel->reboot(null);
} In our project, we encountered
We observed some requests ending with a 500 status code due to a In worker mode, if the entity manager is closed, all requests handled by the worker result in an |
I was facing weird side effects regarding PHP sessions and Doctrine ORM running Symfony 6.x and 7.x applications in FrankenPHP worker-mode.
Rebooting the kernel between requests fixed it.
I had this kind of issues back than using Roadrunner as well, so the reboot strategy implementation is inspired by https://github.com/Baldinof/roadrunner-bundle.
Though I guess an
on_exception
strategy does not make to much sense on a runtime layer (since FrankenPHP will kill the worker if an exception is not handled), it's just 'never' and 'always' for now.