roadrunner-php / laravel-bridge

🌉 RoadRunner ⇆ Laravel bridge 🇺🇦❤️
https://roadrunner.dev/docs/integration-laravel
MIT License
372 stars 25 forks source link

Improve bridge performance and reduce memory consumption #5

Closed wolfy-j closed 3 years ago

wolfy-j commented 4 years ago

At the moment most of the extensions work using symfony/psr-http-message-bridge which converts PSR-7 request/response into Symfony/HttpKernel.

The RoadRunner worker exposes low level API to access the incoming request data in the form of an array.

https://github.com/spiral/roadrunner-http/blob/master/src/HttpWorker.php

Essentially, it makes it possible to skip the PSR-7 implementation as whole and map data directly to Symfony Request/Response.

Benefits:

wolfy-j commented 4 years ago

P.S. we can also add “native” adjective after this patch.

tarampampam commented 4 years ago

Hm, ok, a will think about it

tarampampam commented 3 years ago

About one year later...

I have attempted to implement skipping PSR-7 request creation during the work under the fresh package version, and in two words - it's not worth the gamble. Reasons:

@wolfy-j can I close this issue?

SerafimArts commented 3 years ago

@tarampampam There are really 4.5 transformations going on.

1) RAW Data -> Transport Frame (https://github.com/spiral/goridge-php/blob/master/src/StreamRelay.php#L74) 1.1) Unpacking Frame as HTTP 2) Frame -> DTO Request (https://github.com/spiral/roadrunner-http/blob/master/src/HttpWorker.php#L101-L109) 3) DTO -> PSR Request (https://github.com/spiral/roadrunner-http/blob/master/src/PSR7Worker.php#L91-L101) 4) PSR Request -> Symofny Request (As in the example above)

It is not worth getting rid of the low-level transformations, because there is a binary protocol and all sorts of checks. But it is possible to get rid of the transformations from DTO to PSR and then from PSR to Symfony. They are really unnecessary.

However, I agree that this is not very significant, if the task is not to speed up, but to ensure maximum compatibility and portability in the future =)