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
Add curl handler streaming support #3115
Comments
Can you replicate this in Guzzle 7? Guzzle 6 is EOL. |
Possibly the slow part here is just your choice of size of string to read: |
How long is |
I tried 10GB and 100GB, With 10GB, the speed is about the same. With 100GB I hit php time limit, but the speed would be probably the same too. With Guzzle v7.5.0/latest, I do not see any significant perfomance improvement. The same/no improvement with 100x larger read chunk size. |
Are you able to provide a flame graph so we can determine if this is just PHP being slow, or if we have some bottleneck on our side? Are you using the curl adapter, or the PHP streams adapter? |
I am on Windows, so I cannot provide flame graph, on linux, I tested the perf using phpunit and GH Actions, so getting it would be probably not that easy... I benched the server side with wget I can get > 2GB/s consistently, so the bottleneck has to be on the client side.
I have url open disabled, so probably curl (which is enabled). The Guzzle client is created like: |
Are you able to reproduce it on your side? Is there anything that can be improved in this lib/php-src curl/streams? |
I have not had any time to look into this. If you could get a flamegraph going, that would be helpful. |
The default curl handler eagerly retrieves the full response body into a By setting |
In atk4/ui project we have huge data streaming test: https://github.com/atk4/ui/blob/9ba705b3ced0b99b31b8378b8fdd33774d0647ca/tests/DemosTest.php#L347 I have modified the class to use http by modifying these methods:
With @TimWolla can you please test this with the atk4/ui test? Also as |
I'm not going to debug your non-trivial code-base for you. I've provided the necessary pointers, the rest is up to you. |
The different output suprised me. Thank you. As I have written above I need to use curl anyway as |
With |
ignore this comment, I was using test server with limited response body size
the current impl. already uses it - https://github.com/guzzle/guzzle/blob/7.7.0/src/Handler/CurlFactory.php#L413 - so my question is, what is blocking the curl impl. to allow streaming without intermediate file |
In case using cURL is not mandatory for your here is an alternative: The I was able to prevent caching responses as temporary files by configuring it as follows:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you for your contributions. |
Feature request
Based on the discussione below, it seems the main bottleneck is caching the whole response thru disk. This issue is therefore a feature request to add streaming support for curl handler.
Guzzle version(s) affected: any (6.5, 7.5)
PHP version: any
cURL version: any
Description
PHP internal webserver can serve data at >4 GB/s speed. The biggest bottleneck is Guzzle client which seems to be capped around 500 MB/s.
How to reproduce
Server side:
server.php
cmd:
Client side:
The test pass, but the typical run time is around 2.2 secs on both Windows and linux. I would expect >2GB/s.
Possible Solution
Maybe the response is internally read in small receive buffers etc., IDK.
The text was updated successfully, but these errors were encountered: